Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting environment variables in Classic ASP

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

like image 755
MikeWyatt Avatar asked Jun 15 '11 15:06

MikeWyatt


1 Answers

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"))
like image 76
Alex Avatar answered Sep 21 '22 16:09

Alex