| |
Program Monitor (ProgMon) Macros
PTFB Pro versions 3.4 and above allow to create "program monitor" or "progmon" items. These periodically check to see if a particular program is currently running on your system. Depending on how you've set them up, they'll either launch the target program if it isn't running, or close/kill the program if it is running.
Why would you need this? Well here are a few uses:
- An office computer has utility that should be kept running throughout the day, and sometimes colleagues accidentally quit the utility
- There's a program you'd like to keep running, but sometimes it crashes out without any warning or error
- There's software on your PC that checks for updates (e.g. for the Java runtime). It's OK for them to run when the computer first starts up, but you don't want them running all day because they just consume memory and other resources for no good reason. Stopping them by hand is a pain!
If you'd like to create a program monitor item, the first step is to click the right-hand side of the Macro button on PTFB's screen and choose "New ProgMon Macro", OR choose Options -> New Macro -> New ProgMon Macro. This launches a wizard to help you create the new item.
New Program Monitor Wizard
To read more about the Wizard, please click the links below:
- New Program Monitor - Choose Program
- New Program Monitor - Choose Action
- New Program Monitor - Launch
- New Program Monitor - Close
Other things to be aware of...
- The default item created by the wizard is set to repeat about once every second. If this isn't what you need, you can edit the new item once the wizard has closed, switch to the Triggers page and set up your own trigger conditions, just as you would for any normal macro or single press item. You could even set the item to trigger on a hotkey - thus tieing the launch (or death) of your target program to a handy key sequence.
- If you're aiming to keep an unstable program running, you may find that some of the time the program exits without any warning, while at other times you see the familiar Windows error report "XXX has encountered a problem and needs to close" or similar. If the program simply exits without an error, then PTFB Pro will have no problem re-launching it. However in the case where an error dialog appears, the program actually hangs around until that dialog has been dismissed. Consequently, PTFB Pro will think that the program is still running and won't re-launch it until the dialog has been dismissed. The solution is simple: create an additional single press item to dismiss the error dialog whenever it appears.
- ProgMon Macros are not available on Windows 98 or ME - you must be running NT4 or better to use ProgMon macros.
New Program Monitor - Choose Program
This page lets you tell PTFB Pro which program you want to monitor. It displays a list of all the programs, or to be more accurate, "processes", that are currently running on your PC.
If you see your target program in the list, just select it and hit Next.
If the target program is not in the list, you can still enter it manually in the boxes below the list. The most important field is the process name. This should contain the name of the program/process as it would be displayed in Windows Task Manager. For example, PTFB Pro's process name is PTFBPro.exe (note there's no space). The description field is optional, and is really there just to remind you which program you've picked.
When you've chosen the target program, hit the Next button to move to the next page of the wizard.
NOTE: Under Windows XP, you'll typically see a lot of processes listed - in fact if you've never looked at the Processes tab in Windows Task Manager you may be shocked at just how processes are currently running. Don't be alarmed by this - it's normal - and in particular please don't be tempted to use PTFB Pro to forcibly quit any and all process you don't recognize! Many of those processes will be vital to Windows operation, and if you quit them, your PC may become unstable and require a reboot. Only target programs that you're familiar with!
New Program Monitor - Choose Action
Here, you choose whether you want to launch a program if it's not running, or forcibly stop a program if it is running.
Make your choice and hit the Next button.
New Program Monitor - Launch
Having chosen to have PTFB Pro launch a program whenever it's found not to be running, you now have to tell PTFB Pro how to launch it.
For most programs, it's just a matter of entering the full path to the program's main executable file.
However, in some cases the "program" in question might run as a service, in which case you might use a "net start XXX" command line. Or maybe you want to run a batch (.bat) file, or a vbs script etc. In these cases, enter your command line and tick the "Use cmd console" box. This will cause the command to execute as though you'd entered it into a command console (aka DOS box for those who remember the bad old days...)
One other option for those running under Windows 2000 or better is to cause the command line to execute as though it was issued from a different account. If you want to use this option, just fill in the account name and if appropriate, the corresponding password. The password should be entered twice for confirmation. Note that very few people will need to use the target account option - if in doubt, just leave those three fields blank and your command will run normally.
Test to avoid disappointment!
After you've entered your command details, hit the Test Now button. If anything goes wrong, PTFB Pro will try to give you an error message that will help you fix your command. Common problems include:
- Not enclosing a path in quotes when it contains spaces. For example, if the program resides in the Program Files folder, the command line should look something like this: "C:\Program Files\ProgXXX\ProgXXX.exe" /param1 /param2
- Not having Use cmd console ticked when it is needed
- Having Use cmd console ticked when it isn't needed!
New Program Monitor - Close
Having chosen to have PTFB Pro terminate a program when it is found to be running, you now need to tell PTFB Pro just how to carry out the close operation.
There are three options:
- Request Quit
As the name suggests, this is the most polite method. It sends a message to the program's main window, telling it to close down. It's the preferred method, but not all programs will play fair, and a heavier handed approach may be required.
- Forced Exit
This is the most heavy handed method. PTFB Pro dons its "Terminator" shades and bikers jacket and goes about its business with ruthless efficiency. Assuming the termination succeeds, the unfortunate program gets no chance to close down cleanly. Under certain circumstances this can make Windows unstable, and/or lose data entered in that session. Use with care, and please do not shutdown any processes that Windows depends on!
- Use Cmd Line
If you wish, you can provide your own command line which will be used to terminate the target program. For example, you could use the extra functionality in a tool such as PSKILL to close the program in a specific way, or in the case of a service, you could request a controlled shutdown using the "net stop XXXX" command.
The command line you provide may contain the special parameter {{ProcID}}. When PTFB Pro executes the command line, it automatically substitutes the process ID of the target program in place of the {{ProcID}} variable. Note that this variable is case sensitive - must have a capitalized 'P' and 'ID'.
You can also instruct PTFB Pro to execute the command line as though you'd entered it into a command console (formerly known as a DOS box). To do this, just tick the "Run from command console" checkbox.
|