Function Reference


Refreshes the OS environment.

EnvUpdate ( )

Return Value

Success: none.
Failure: sets the @error flag to 1.


Similar effect as logging off and then on again. For example, changes to the %path% environment might not take effect until you call EnvUpdate() (or you logoff/reboot).


EnvGet, EnvSet


#include <MsgBoxConstants.au3>


Func Example()
        ; Retrieve the system environment variable called %PATH%.
        Local $sEnvVar = EnvGet("PATH")

        ; Assign the system environment variable called %PATH% with its current value as well as the script directory.
        ; When you assign an environment variable you do so minus the percentage signs (%).
        EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)

        ; Refresh the OS environment for changes to take affect.

        ; Retrieve the system environment variable that was just assigned a value previously.
        $sEnvVar = EnvGet("PATH")

        ; Display the value of the environment variable $PATH%.
        MsgBox($MB_SYSTEMMODAL, "", "The environment variable %PATH% has the value of: " & $sEnvVar)
EndFunc   ;==>Example