Read System Environment Variable from ASP w/o any dll

Posted on 2005-04-11
Last Modified: 2012-06-22
Need to access a system/user environment variable (of the server) from ASP. Haven't done anything like that till now and Googling dint help. Can't believe such a common scenario has no solution in ASP! Well, if there is a way, ppl here wld know! ;)

please help me to...

- Read a System environment variable like PATH (NOT session/application/servervariable)
- Without using a dll
- A round-about way involving SQL server should be okay
Question by:fozylet
    LVL 1

    Expert Comment

    ASP is a framework, it's functionality is dependant on COM objects, the only ones built in (no 3rd party dll involved) are Response, Request and Server, these are purposefully of limited scope and cannot achieve what you want alone.

    Server does provide .CreateObject, if permissions allow you could use this to invoke which I believe can access the variables you want.

    As for a round-about way involving SQL server, most installations are locked down to the level of ASP, if this is on a shared hosting platform (assuming that's your reason for ruling out a COM dll), have you considered that the host does not want users accessing machine-level information?

    If for some reason you do have full access to SQL Server but not wscript, you could use DTS + ActiveX Script packages to do this for you.
    LVL 6

    Expert Comment

    In ASP.NET, you can use the environment class, see

    In ASP you should invoke the cmd interpreter, using pipes to create a file. (eg. PATH > pathtext.txt {create a file with as content the result of the path command} )

    Then read that file and parse it.

    LVL 1

    Accepted Solution

    I decided to test

    dim wshell : set wshell = Server.CreateObject("")

    Worked as expected, but this is on my own machine, if your on a professional host, this should cause a security error message.

    P.S. To turn %vars% into meaningful data you can enclose it in a wshell.ExpandEnvironmentStrings() call.

    LVL 8

    Author Comment


    great explanation! :)
    am aware of the limitations and that is why i was sure a pure asp solution will not work. using WSH should be okay since WSH is installed as a standard add-on in most cases. the reason i ruled out a component is coz of the requirement at hand, not coz of remote hosting.

    in short, ur solution works perfect! thank you! :)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now