<< Click to Display Table of Contents >> Running a program when SpecView exits |
![]() ![]() ![]() |
A program can be run when SpecView exits. The program is run in the same way as when using the action Run External Program.
This can be used to:
- Send an eMail to indicate that someone exited SV
- Restart SpecView if SpecView is exited
- Display a message
- Copy files to another location automatically on exit, for example, to copy debug files into a different folder to preserve them
To do this follow these steps:
In the SETTINGS.INI file for the Project add this line to the '[SETTINGS]' section:
ExitProgToRun=C:\SV3\RUNME.BAT
Then, when SpecView has finished running that Project and is exiting, it will run the Batch file.
Note: does not work if SpecView exits abnormally, it will only run of SpecView exits normally.
The RUNME.BAT file should do whatever is required. This could be, for example:
@ECHO OFF
CD \SV3
START /MIN ProgramToRunMinimized.exe
EXIT
Here are three interesting examples that can be done:
(Note: the @echo off prevents to steps being listed on the screen, and the EXIT closes the command prompt when finished.)
1. Display a Message Box on the screen (Also useful in normal RunExternal program while SV is running)
Save and unzip the attached Usermessage.vbs in the SV3 folder, then the batch file would be:
@ECHO OFF
CD \SV3
WSCRIPT usermessage.vbs
EXIT
This example .vbs has a 10 second timeout on the message, which can be useful. The .vbs file is a text file, so it can be easily changed to the message of choice.
2. Copy COMMS debug files from the project folder (e.g. MyProject) to a subfolder named by date to save them before the next run of SpecView overwrites them:
@echo off
cd \sv3\MyProject
setlocal enableextensions
for /f "tokens=1-5 delims=:" %%d in ("%time%") do SET MassTime=%%d-%%e-%%f
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do SET MassDate=%%d-%%e-%%f-%%g
set foldername=DebugsFrom_%MassDate%_%MassTime%
REM folder looks like this: DebugsFrom_17_12_2014_16_02_47.70
md %foldername%
MOVE debug*.txt %foldername%
EXIT
3. Restart SpecView after a short (10 second) delay. Starts SpecView Maximized instead of minimized.
@ECHO OFF
CD \SV3
TIMEOUT /T 10
START /MAX SV3.EXE
EXIT
1 & 3 could be combined together to display a message informing the user that SpecView is being restarted.