Kaseya Community

Need help creating a script to create an environment variable

  • Hi,
    I need to create a script to crete an environment variable as described by an Autodesk technote article below. I tried creating a vbs following instructions from the Scripting guy (http://www.microsoft.com/technet/scriptcenter/resources/qanda/mar05/hey0318.mspx).

    The script doesn't do anything. Does anybody have any ideas on what I am doing wrong?

    Thanks in advance.

    SCRIPT FROM THE SCRIPTING GUY
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set objVariable = objWMIService.Get("Win32_Environment").SpawnInstance_

    objVariable.Name = "ADSKFLEX_LICENSE_FILE"
    objVariable.UserName = "System"
    objVariable.VariableValue = "@server.domain.local"
    objVariable.Put_[/code]




    AUTODESK INSTRUCTIONS
    To use an environment variable to specify one or more license servers for your Autodesk products
    1. On theStart menu (Windows),click Settings > Control Panel.
    2. Double-click System.
    3. In the System Properties dialog box, click the Advanced tab.
    4. ClickEnvironment Variables.
    5. Under System Variables,click New.
    6. In the Variable Name box,enter
    7. ADSKFLEX_LICENSE_FILE
    8. In theVariable Value box,enter the license server(s)in the following format:
    [indent]@server1;@server2;@server3 (where server is the hostname or IP address of your license server)
    [/indent]
    1. Click OK to close each dialog box.



    Legacy Forum Name: Need help creating a script to create an environment variable,
    Legacy Posted By Username: lonenlonen
  • The easiest way to create one would be to set it in the registry.

    Note: after setting one it takes a reboot for it to take affect.

    User environment variables are stored in the Registry in the key

    HKEY_CURRENT_USEREnvironment

    System variables are found in the key

    HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerEnvironment

    Note: that any environment variable that is in the form that needs to be expanded (for example, %PATH%) must be stored in the registry as a REG_EXPAND_SZ registry value.

    I got this information from this location.

    http://vlaurie.com/computers2/Articles/environment.htm

    Hope this helps you out.


    Legacy Forum Name: Script Discussion,
    Legacy Posted By Username: rumptis