Getting environment variables in Classic ASP

前端 未结 2 1551
予麋鹿
予麋鹿 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:24

    The following worked for me, based on this article

    Set objWSH =  CreateObject("WScript.Shell")
    'This actually returns all the User Variables, and you either loop through all, or simply print what you want
    Set objUserVariables = objWSH.Environment("USER") 
    MsgBox(objUserVariables("TEMP"))
    
    'This returns all the System Variables, and you either loop through all, or simply print what you want
    Set objSystemVariables = objWSH.Environment("SYSTEM")
    MsgBox(objSystemVariables("PATH"))
    

提交回复
热议问题