Add system variables to machines PATH

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! :slight_smile:

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)