函数参考


EnvSet

写入或修改一个环境变量.

EnvSet ( "环境变量" [, "值"] )

参数

环境变量 环境变量名.
[可选参数] 目标环境变量的值.使用时若没有指定此参数则该环境变量将被删除.

返回值

成功: 返回非0.
失败: 返回 0.

注意/说明

此函数设置的环境变量只能被那些由 AutoIt 启动的程序(比如使用Run或RunWait)访问.一旦 AutoIt 被关闭则该环境变量将不复存在.

相关

EnvGet, EnvUpdate

示例/演示


Example()

Func Example()
    ; Create an environment variable called %MYVAR% and assign it a value. When you assign or retrieve an envorinment variable you do so minus the percentage signs (%).
    EnvSet("MYVAR", "This is some text!")

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

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