函数参考


EnvUpdate

刷新操作系统的环境变量.

EnvUpdate ( )

参数

None.

返回值

成功: 无.
失败: 把 @error 设为 1.

注意/说明

效果等同于注销系统然后再登陆(这是让环境变量的改动生效的一般做法,当然还有其它更好的).比如说,我们对环境变量 %path% 做了某些修改,为了让它立即生效就要调用 EnvUpdate 函数(否则就要注销/重启).

相关

EnvGet, EnvSet

示例/演示


Example()

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 envorinment variable you do so minus the percentage signs (%).
    EnvSet("PATH", $sEnvVar & ";" & @ScriptDir)

    ; Refresh the OS environment for changes to take affect.
    EnvUpdate()

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

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