Getting environment variables in Classic ASP

前端 未结 2 1757
予麋鹿
予麋鹿 2021-02-19 20:03

How can I get the value of a custom environment variable in a classic ASP page using VBScript?

2条回答
  •  没有蜡笔的小新
    2021-02-19 20:34

    You can use the ExpandEnvironmentStrings method of the WScript.Shell object to retrieve environment variables. The following code will assign the value of the PATH environment variable to var myPath:

    set foo = createobject("WScript.Shell")
    myPath = foo.ExpandEnvironmentStrings("%PATH%")
    

    More info on the Shell object as MSDN

    Edit: Had to change the variable to which the shell object is assigned.

提交回复
热议问题