Kaseya Community

agent procedure to write/add to the 'path' environment variable

This question is not answered

We have some new software, and one of the prerequisites is to write a value to the 'path' environment variable.  Obviously I do not want to overwrite what is there, just add to the list.  Has anyone come up with a good way of accomplishing this through an agent procedure?

Thanks for your assistance.

All Replies
  • Overall it's pretty straightforward to make a change to the path as it's stored in the registry.    I've not done it specifically with an agent procedure but I've done it with powershell before.

    The registry containing the "PATH" environment variable is HKLM\System\CurrentControlSet\Control\Session Manager\Environment\Path

    On newer systems that's a REG_EXPAND_SZ.  What I've done with powershell before is simply read the value into a variable, append what I need to it, and then write it back out.  It should be possible to do something similar with an agent procedure.

    The main caveat here is that changing the path via the registry like this doesn't actually take effect until the next system restart. (or if you kill explorer.exe and restart it.)

    Made it a suggested answered.
    [edited by: Jonathan at 7:30 AM (GMT -7) on Jul 12, 2018]