windowsbatch-filepathpsexecsetx

"ERROR: Invalid syntax. Default option is not allowed more than '2' time(s)." using SETX


I thought I had this working at one time but recently my command quit working. My research here and abroad is not turning up anything I have not attempted already. Perhaps there is some other variable I am missing that SETX is looking at?

My command:

setx /s servername PATH "%Path%";"c:\program files (x86)\java\jre7\bin";"c:\program files (x86)\java\jre7\bin\client" /m

I have tried the same command against a couple of Win2k8 servers to no avail. This has worked but is now producing the error above. I usually run this within a batch file against a list of several servers to push Java out. (Path to java is not being set unless we manually create the entries when remotely installed.)

The existing path on the server I am attempting to update is this:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%systemroot%\System32\WindowsPowerShell\v1.0\;C:\BMC\Patrol3\bin;C:\BMC\common\globalc\bin\Windows-x86;C:\BMC\common\globalc\bin\Windows-x86-64;C:\BMC\Patrol3\BEST1\9.5.00\bgs\bin

I did clean up a couple duplicate path entries. Aside from that I did not find anything unusual to me.


Edit: Tweaking the command to remove some of the quotation marks does allow it to run but with that, it imports the path of the local system replacing the remote systems path and appends the desired path entries.

The revised command:

setx /s servername PATH "%Path%;c:\program files (x86)\java\jre7\bin;c:\program files (x86)\java\jre7\bin\client" /m

In hopes of fixing this new problem, I am attempting to run the command with psexec. Doing so brings me back to my original problem, "Default option is not allowed more than '2' time(s)". Depending on how I modify the quotes when using psexec I can get "To many Arguments" or command succeeded, path truncated which ends up being the local path being applied on the remote server once again.

The most promising of my attempts:

psexec \\servername -u domain\user -p p@ssw0rd "c:\windows\system32\setx" "Path "%Path%;c:\program files (x86)\java\jre7\bin;c:\program files (x86)\java\jre7\bin\client" /M"

Using the "-s" option on psexec produces the same error, just less detail.


Solution

  • I was able to update the path value on remote systems by creating a batch file to be executed remotely.

    Contents of "setJava7path.cmd"

    setx Path "%Path%";"%ProgramFiles(x86)%\java\jre7\bin";"%ProgramFiles(x86)%\java\jre7\bin\client" /m
    

    To execute I utilized psexec which copied the batch file to the remote system and executed the command.

    psexec \\systemname -c setJava7path.cmd
    

    It adds / changes a line to my overall deployment script but that is livable.