|
STOP PRESS - Macro Scheduler 8.0 Provides a Scheduler Service and AutoLogon Technology.
The information below is no longer necessary for Macro Scheduler 8.0 and is
relevant only to version 7.4 and below.
Macro Scheduler itself doesn't run as a service. Macro Scheduler macros, however, can run as services. Running Macro Scheduler itself as a service is unnecessary. You are actually likely to want to do one of the following two things:
1) Be able to schedule a script to take place when the machine is logged out.
2) Have a script running all the time, even when the machine is logged out (and scripts themselves can be made to do scheduling, or run other scripts based on certain events).
Both of these can be done, and I will explain how to do so in just a moment. First we must be aware that GUI macros, i.e. ones that control the mouse and keyboard and 'watch' Windows and perform tasks with other Windows, will NOT work when the machine is logged off. This is because in this state Windows do not exist. The console, that lets you use the keyboard and mouse, simply doesn't exist when the machine is logged out. Macro Scheduler does GUI automation by simulating a user and must therefore have the same access as the user. Since the user needs to be logged in to use the Windows interface, so must Macro Scheduler. Macros that do not do any user simulation can run while Windows is logged out.
Scenario 1 - scheduling a script to take place when the machine is logged out - can be taken care of simply by scheduling the macro with Windows Scheduler, or AT (or any other scheduler that runs as a service). Windows Scheduler/AT run as a service so will be able to start the macro on schedule even if the machine is logged out.
Scenario 2 - running a script as a service - is achieved by using Microsoft's SrvAny utility and it's installer InstSrv. This is available with the Windows Server Resource Toolkit from Microsoft.
The easiest and most efficient way to run a script as a service is first to compile it to a .exe file. We then only need to run the .exe itself as a service. However, we can run Macro Scheduler with the script file as a parameter as a service, but this would be less efficient as more resources are used by redundant Macro Scheduler functions that aren't being used by the script. Both methods are explained here.
Step 1) Install the service:
It is easiest to have SrvAny, InstSrv and your script file or compiled script .exe in the same directory. Go to a "DOS" command prompt and navigate to this directory. At the DOS prompt type:
INSTSRV ServiceName PATH\SRVANY.EXE
Where ServiceName is the name to call the service (probably the same name as your script) and PATH is the full path to the directory containing SrvAny.exe. Later you will identify the service in the Services applet in the Control Panel with the name given in ServiceName.
Step 2) Add a registry key:
Run REGEDIT.EXE
Open the HKEY_LOCAL_MACHINE key, then SYSTEM, CurrentControlSet, Services. In here you will see a long list of all your services. One of these will be what you called ServiceName in step 1. Open the ServiceName key.
Step 3) Add the 'Parameter' key:
Right click on the ServiceName key and select "New" and then "Key". Rename this new key "Parameters"
Step 3) Add the 'Application' value:
Open the new Parameters key. Right click in here and select "New" and then "String Value". Call this value "Application".
Step 4) Enter the .exe or script file to run:
Double click on this new Application value. In the Edit String box that appears, in the Data value box enter one of the following, depending on whether you want to run a .exe or a script file:
For a compiled .exe file simply enter the full path and name of the exe file, e.g.:
c:\myservices\myscript.exe
For a script file, enter the full path to Macro Scheduler and the Macro Scheduler executable followed by the path and filename of the script to run, e.g.:
"c:\program files\MJT Net Ltd\Macro Scheduler\msched.exe" "c:\myscripts\scriptfile.scp"
That's it for the registry editor.
Step 5) Starting the service/Setting Service Properties:
In Control Panel find the Services applet. These days this is under the Administrative Tools icon. You will see the new service in the list. It is currently not running but by default will be set to Automatic which means it will start next time you start the machine. You can start the service here manually, and/or change the properties. Some scripts may need to work in a particular security context, for network access for example. You can set which account to allow it to run under here (Under the "Log On" tab in XP).
Your script will now run in the background as a service and will continue to run when the machine is logged off.
For more information and how to use SrvAny and InstSrv please see these useful articles:
http://www.winnetmag.com/Windows/Article/ArticleID/8148/8148.html
http://www.winnetmag.com/Article/ArticleID/7959/7959.html
Back To Index
|