Using %SystemRoot% in CmdExec Job Step

  • Hi is it possible to use %SystemRoot% as part of a CmdExec command in a Job Step?

    Some of our older servers have Windows installed in C:\WinNT which causes issues when we use a script to create jobs because at the moment we have C:\Windows hard coded as part of the command created for a particular job step. Rather than have to manually change the job step for the older servers each time the job is recreated I would like to make the job creation script either more intelligent or use %SystemRoot%.

    If I specify %SystemRoot%\System32\... rather than C:\WinNT\system32 in the job step I get the following message when I try and execute it:

    The process could not be created for step 5 of job 0x4B03E91FA3D46642A82A421A8C1BA761 (reason: 2). The step failed.

    I have tried using " " around the command but that doesn't work either.

  • SQL Server should not be anywhere around System32 folder.

    What do you want to do in there?

    _____________
    Code for TallyGenerator

  • Hi, it is part of a backup routine and is trying to run C:\WINDOWS\system32\cscript.exe

  • If you need just to run a program in System32 you don't need to include folder in the command at all.

    This folder should be registered in PATH variable and cscript.exe should start being called just by name from any location.

    D:\cscript.exe works perfectly on my machine.

    _____________
    Code for TallyGenerator

  • Doh! That does indeed work. Sometimes we look for the complicated solution when an easy one will do.

    Thanks for your help.

  • I have an environment variable called

    test2

    where test2 = c:

    I am trying to run a cmdexec step in SQL Agent of SQL 2005. I specify

    %test2%\jer2.cmd

    It always bombs with this

    "The process could not be created for step 1 of job 0x4E97EB9AC533714292A7BABDDA6E9F22 (reason: The system cannot find the path specified). The step failed."

    However,

    if I go

    c:\jer2.cmd it works.

    If I go dir %test2% > c:\jer2.out

    this also works.

    Look like cmdexec does not like environment varaibles at the beginning? Any ideas?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply