2 Replies Latest reply on Sep 27, 2016 10:16 AM by mmajeres

    Creating a user environmental variable

    mmajeres Apprentice

      Is there a best practice for creating a user environmental variable in LDMS 2016?  I have an install that needs to set a variable, but won't run as current user, so I thought I'd bundle it with a custom Windows Action package, or a powershell package that runs something like:


      [Environment]::SetEnvironmentVariable("TestVariable", "Test value.", "User")



      If I run a powershell script it (understandably) fails to make a change because of the execution policy on endpoints, which is NOT "Unrestricted"

      A custom Window action reports success, but doesn't appear to create the variable.


      Any thoughts, or has anyone got a good solution?

        • 1. Re: Creating a user environmental variable
          phoffmann SupportEmployee

          So Windows actions are generally powershell packages - so "same issue" as it were.


          Generally, it's not so much a BKM for this, as "whatever will do it for you". So whether you use VB or a batch doesn't matter in the end . Personal preference.


          That said, I've not had to create a new Environment variable in some time (and can't find any "dirty notes' on doing so of my own) ... the following (googl'ed up) links may help you though:


          If you've locked down PowerShell, you may have to look elsewhere for it - and remember that you can launch a package in a user context. Local System *SHOULD* be enough though for this - but depending on what you're after, you may need to launch it as a specific admin (if you need to access domain data, for instance, which LOCAL SYSTEM generally won't be able to).


          Hope that helps you along a bit?

          1 of 1 people found this helpful
          • 2. Re: Creating a user environmental variable
            mmajeres Apprentice

            What I ended up doing, and think ought to be a good solution for others was this.


            I created a Windows action package that adds a registry key under HKCU/Environment.  Because it was a user variable I use the current user's account to run the package. If it was a system variable, it would be in HKLM and could run a LocalSystem.

            1 of 1 people found this helpful