Command Line Options
It is possible to run macros from the command line using the following syntax:
msched macroname
e.g. to run the Defragment Disk example script you would type:
msched Defragment Disk
This is useful for creating shortcuts and running Macro Scheduler scripts from other programs or from macros created in other applications such as Word or Excel.
However, if you want to create a shortcut, you can get Macro Scheduler do it for you. See Creating Desktop Shortcuts.
Parameters
When running a Macro from the command line in this way, you can also pass parameter values into the script :
msched Example Script /filename=testfile.txt /path=c:\outpath\
The above example runs a script called 'Example Script' and passes two variable values in filename and path. These variables can be used in the usual way within the script, e.g. :
Change Directory>path
ifFileExists>filename,ok
Goto>end
Label>ok
Message>File Exists !!
Label>end
It is also possible to run any file by passing the full path and filename to Macro Scheduler like this :
msched c:\scripts\my script.scp
In this instance, the script 'my script' does not have to exist in the Macro Scheduler macro list. If you wish you can associate .scp files with Macro Scheduler so that Macro Scheduler scripts can be run by double clicking on them in explorer.
The same method can be used for compiled scripts:
compiledmacro.exe /fullname="Donald Duck" /filename=testfile.txt
Note that quotes can be used to surround values that contain spaces.
Log File
You can specify a log file for the macro by passing the LOGFILE variable:
msched.exe c:\scripts\my script.scp /LOGFILE=c:\mylogfile.log
As this is passed as a script variable it will also be available to the macro as a regular variable.
It is not necessary to specify a log file if running a macro using only the macro name for a macro that already has logging enabled. In this case the log file settings for that macro will be used. However, if the LOGFILE parameter is passed it will override the macro's existing logging settings. The LOGFILE parameter can also be used with compiled scripts.
Normally each time a line is added to the log file the log file is opened, the line is written and the file is then closed again. This ensures reliability and prevents possible issues with files being left open or locked if a problem should occur mid way through the script. However in some very demanding production scenarios (e.g. thousands of multiple running scripts logging to the same file) this can introduce a performance penalty. In this situation you may want to keep the log file open during script execution. This can be done by adding the KEEPLOGOPEN switch to the command line.
Script URLs
The script file can also be an HTTP URL, so that you can run macros from the web:
msched.exe http://www.mjtnet.com/scripts/sample.scp
If you need to specify a username and password to access the script do so as follows:
msched.exe http://username:[email protected]/scripts/sample.scp
Opening the Editor
To run Macro Scheduler in macro editor mode, use the -EDITOR switch:
msched.exe -EDITOR
To open a script file directly in the Macro Scheduler editor, add the filename to the command line:
msched.exe -EDITOR c:\myscripts\somescript.scp
Disabling System Tray Support
To switch off system tray support, so that the Macro Scheduler icon does not show in the System Tray add the parameter -NOSYSTRAY or /NOSYSTRAY at the end of the command line :
msched -NOSYSTRAY
Hiding Macro Scheduler
You can hide the Macro Scheduler window with the -HIDE parameter:
msched -HIDE
To hide Macro Scheduler completely use this in conjunction with the -NOSYSTRAY parameter:
msched -HIDE -NOSYSTRAY
-HIDE and -NOSYSTRAY can also be used with compiled macros.