EnvUpdate
刷新操作系统的环境变量.
EnvUpdate ( )
返回值
成功:
|
无返回值.
|
失败:
|
设置 @error 为 1.
|
备注
效果等同于注销, 然后重新打开. 例如: 修改 %path%, 环境变化可能不会立即生效, 必须调用 EnvUpdate (或者注销/重启).
函数示例
#include <MsgBoxConstants.au3>
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 environment 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($MB_SYSTEMMODAL, "", "The environment variable %PATH% has the value of: " & $sEnvVar)
EndFunc ;==>Example
----------------------------------------
该函数可以通过命令 exect 调用
参见:
EnvGet, EnvSet
$var_env=EnvGet('PATH')
;;将值环境变量%PATH%分配给其当前值与当前脚本的目录.
;; 在一个环境变量的任命,使用它没有"兴趣"(%).
EnvSet('PATH',$var_env&';'& @ScriptDir)
;; 更新操作系统环境的环境,使更改生效.
EnvUpdate()
;; 获取先前分配的环境变量值.
$var_env = EnvGet('PATH')
© Аверин Андрей для Total Commander Image Averin-And@yandex.ru
|