Windows Environment Variables after Exec Command
Is it possible to set/add environment variables with Puppet. Let's say the %PATH% environment variable.
Not sure why. But it seems that Puppet was adding their own directories to the PATH. I used the following script to be executed with powershell.
$nodistPath = ";C:\Program Files (x86)\Git\bin" $actualPath =[Environment]::GetEnvironmentVariable('Path',[System.EnvironmentVariableTarget]::Machine) Write-Host "System Path = $actualPath " $actualPath = $actualPath + $nodistPath Write-Host "Modified Path = $actualPath " [Environment]::SetEnvironmentVariable('Path',$actualPath,[System.EnvironmentVariableTarget]::Machine)
This can be done using the setx command on windows. setx with a /m switch will set the machine path. I believe this won't take effect until you initiate a new session (ie close and re-open cmd) or explorer.
You can use an exec resource. You may need to cmd /c setx. Or you can do this via powershell provider. Or via the registry- HKLM\System\CurrentControlSet\Control\Session Manager\Environment'
Or a combination of both is something I might try- http://mnaoumov.wordpress.com/2012/07/24/powershell-add-directory-to-environment-path-variable/
Asked: 2013-05-13 08:17:02 -0500
Seen: 857 times
Last updated: May 19 '13