Add system variables to machines PATH

//Add system variables to machines PATH
Add system variables to machines PATH2016-01-29T07:22:08+00:00

The Toolkit Forums General Add system variables to machines PATH

  • Author
  • Johan
    Post count: 4

    Im trying to add one more variable to the machines PATH in windows 7.
    In cmd the commandprompt it works great.

    setx /M path “%path%;C:\tttttt 222”

    But when im trying to do this in Ps appdeploy is just override the current path and does not add the variable.

    Execute-Process -Path “setx” -Parameters “/M PATH “%path%;C:\test2222”

    Please help! 🙂

  • Muhammad Mashwani
    Post count: 118

    When you use the command prompt to execute the setx command, the %path% variable is interpreted by the command prompt (cmd.exe) not by setx.exe.

    In the PowerShell command, you are executing setx.exe and passing it a %path% variable it does not understand.

    To get the same results, you would need to execute cmd.exe instead of setx.exe.

    I would suggest a PowerShell method for changing the path environment variable:
    [Environment]::SetEnvironmentVariable(‘Path’, $env:Path + “;C:\test2222”, [EnvironmentVariableTarget]::Machine)

You must be logged in to reply to this topic.