在Classic ASP中获取环境变量

问题描述

| 如何使用VBScript在经典的ASP页中获取自定义环境变量的值?     

解决方法

        您可以使用WScript.Shell对象的ExpandEnvironmentStrings方法来检索环境变量。以下代码将PATH环境变量的值分配给var myPath:
set foo = createobject(\"WScript.Shell\")
myPath = foo.ExpandEnvironmentStrings(\"%PATH%\")
有关Shell对象作为MSDN的更多信息 编辑:不得不更改将外壳对象分配给的变量。     ,        根据本文,以下内容对我有用
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,or simply print what you want
Set objSystemVariables = objWSH.Environment(\"SYSTEM\")
MsgBox(objSystemVariables(\"PATH\"))
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...