How to set environment variable permanently

(imported topic written by rmustapha91)

Is there anyway to permanently set environment variable through Bigfix action script?

I’m installing perl and for the this application to function well, I will have to set some environment variables for it but I don’t want to do it manually. I tried using command below in my action and it doesn’t work.

cmd /c set /M PATH “%PATH%;c:\perl\bin”

I also tried to use regset command to directly set it in the registry still it doesn’t work.

regset "

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControllerSet\Session Manager\Environment

" “Path” =";c:\perl\bin"

Please I need help. Thanks

(imported comment written by BenKus)

Hi ralph,

It is possible that this is working, but only in the context of the SYSTEM account… but note that you have an extra space in your action (before the “=”):

regset “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControllerSet\Session Manager\Environment” “Path”=";c:\perl\bin"

Ben

(imported comment written by rmustapha91)

Thanks for the suggestion, I will look into it. But what of if I want the regset to work for every account. What should I do?

(imported comment written by rmustapha91)

I was able to use this style and it worked but the only carvioc was that it overwrite the existing value. All I want to do is to append to the existing value . could you please help?

delete __appendfile

delete perl_environmentVt.reg

appendfile REGEDIT4

appendfile

appendfile

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

appendfile “Path”=“c:\perl\bin”

appendfile

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

appendfile “PATHEXT”=“PL”

move __appendfile perl_environmentV.reg

waithidden regedit /s “perl_environmentV.reg”

(imported comment written by BenKus)

You can look up the value and stick it in the path… like this:

appendfile “Path”="{escapes of (value “Path” of key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment” of registry as string)};c:\perl\bin"

Ben