2

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.

gritts
  • 177
  • 1
  • 3
  • 13
  • 2
    The quotes look weird to me; try to remove them and enclose the *entire* value within `""`... – aschipfl Oct 29 '15 at 00:24
  • Those quotations worked fine when I ran within a script. Changing the quotes gets rid of the error. Now the local path is being applied to the remote server with the path I wanted to append. – gritts Oct 29 '15 at 13:02
  • @gritts I suggest to look on the answers on [Why are other folder paths also added to system PATH with SetX and not only the specified folder path?](http://stackoverflow.com/a/25919222/3074564) and [setting path environment variable in batch file only once on Win7](http://stackoverflow.com/a/31889785/3074564). Expanding system __PATH__ correct on a remote machine is of course even more difficult than it is already on local machine. – Mofi Nov 01 '15 at 17:28

1 Answers1

2

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.

gritts
  • 177
  • 1
  • 3
  • 13