Local Scheduler requires additional quotes in command line parameters

Version 6

    Verified Product Versions

    Endpoint Manager 9.6Endpoint Manager 2016.xEndpoint Manager 2017.x



    Local Scheduler command line parameters requires 3 quotes rather than the traditional 1 or 2 quotes.  This occurs in all versions from 8.7 and prior.


    Certain command line parameters need quotes.  When such commands are called with local scheduler, they fail unless the correct number of quotes are used.  If one or two sets of quotes are added, the command line is cut off at the first space.  If a third set of quotes are added, it works.  This is the case regardless of whether the command line is built at an actual command line or in the console using the Local Scheduler Script wizard.




    The following command line will be used as an example.


    wscript.exe "c:\program files\someapp\vbscript.vbs"


    To have this run in Local Scheduler, the quotes need to be included in the Local Scheduler command prompt:


    localsch.exe /exe="wscript.exe" /cmd="C:\Program files\vbscript.vbs" /taskid=1001 /freq=86400


    Now look at the tasks by executing  localsch /tasks |more

    wscript.exe C:\Program Files\vbscript.vbs     handle    : 1001     start    : Wed Dec 31 17:00:00 1969     frequency : 86400

    Note: This will not work because C:\Program Files\vbscript.vbs needs to be surround in quotes.  If it is not surrounded in quotes, then it is passed to wscript.exe as two parameters, where the first parameter is  C:\program and the second parameter is Files\vbscript.vbs.  This is not correct.  It needs to be one single parameter.


    Delete that task by executing the following command: localsch.exe /del /taskid=1001


    Add quotes inside the quotes in the command line parameters and re-apply the local scheduler task:


    localsch.exe /exe="wscript.exe" /cmd=""C:\Program files\vbscript.vbs"" /taskid=1001 /freq=86400


    Look at the result by executing localsch /tasks |more

    wscript.exe "C:\Program     handle    : 1001     start    : Wed Dec 31 17:00:00 1969     frequency : 86400

    Note: Despite the quotes, the line ends after the first space, which obviously fails.


    Delete that task by again executing: localsch.exe /del /taskid=1001

    Finally, add a third set of quotes and re-apply the local scheduler task:


    localsch.exe /exe="wscript.exe" /cmd="""C:\Program files\vbscript.vbs""" /taskid=1001 /freq=86400

    Look at the result by again executing  localsch /tasks |more


    wscript.exe "C:\Program Files\vbscript.vbs"     handle    : 1001     start    : Wed Dec 31 17:00:00 1969     frequency : 86400

    Note: This local scheduler task is handled properly.



    The design has to do with the fact that the scheduler is parsing a command line that may contain multiple commands. While the previous example could be parsed with two quotes, like this:


    localsch.exe /exe="wscript.exe" /cmd=""C:\Program files\vbscript.vbs"" /taskid=1001 /freq=86400


    If the administrator needed to pass two parameters with spaces to local scheduler then the double quotes do not work, for example:

    localsch.exe /exe="wscript.exe" /cmd=""C:\Program files\vbscript.vbs" "C:\documents and settings\allusers\somedata.file"" /taskid=1001 /freq=86400


    Since this cannot be properly interpreted, the scheduler requires three quotes: one to indicate we are entering and then two to indicate an escaped quote.  So the command line with the two parameters appears as follows and can be interpreted:


    localsch.exe /exe="wscript.exe" /cmd="""C:\Program files\vbscript.vbs"" ""C:\documents and settings\allusers\somedata.file""" /taskid=1001 /freq=86400


    This results is an awkward looking command line when there is only one parameter that has a space in it as shown below:


    localsch.exe /exe="wscript.exe" /cmd="""C:\Program files\vbscript.vbs""" /taskid=1001 /freq=86400



    Use a third set of quotes when passing parameters to the Scheduler.

    Single Quoted Parameter

    localsch.exe /exe="wscript.exe" /cmd="""C:\Program files\vbscript.vbs""" /taskid=1001 /freq=86400

    Multiple Parameters with quotes

    localsch.exe /exe="wscript.exe" /cmd="""C:\Program files\vbscript.vbs"" ""C:\documents and settings\allusers\somedata.file""" /taskid=1001 /freq=86400