0

Need to set-up system variable on remote machine. Performing

psexec \\remote_machine cmd /c setx foo bar

got reply

Success: Entered value was saved
cmd exited on remote_machine with error code 0

But when new console window started on remote_machine and command

set foo

was entered, got reply

system variable foo not defined

what am I doing wrong?

Both machines running windows 7, no AD environment present

0

To set system variables add the parameter /m to the setx command and make sure the command is run with an administrative account.

psexec \\remote_machine cmd /c setx foo bar /m

If you don’t specify /m the variable is only set for the currently logged on user. In the case of using psexec it will be whatever user psexec is run as. If you subsequently log on to the computer with a different user account the variable will not be present.

  • Does not help, same situation with /m switch – user2956477 May 13 at 10:17
  • @user2956477 Then you aren’t running with a user that has administrative access on the remote machine. I tried to explain that. You can try adding /s to the psexec command. How are you authenticating if these machines aren’t in a domain? – Appleoddity May 13 at 11:47
  • Just tried to search windows registry for variable name 'foo' and it is writen in HKCU/Environment, but not displayed on newly created cmd.exe window by command 'set foo' – user2956477 May 13 at 13:27
  • I am using same username with same password on both machines, thus no interactive authentication needed. – user2956477 May 13 at 13:29
  • @user2956477 some of your posts are a bit misleading. You said you want to create a “system” environment variable. Those would not show up under HKCU but instead in HKLM. System variables are system wide, for all users. This the suggestion to add /m. It’s not clear what you want? Use echo %foo% if you want to see that variable. – Appleoddity May 13 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.