get environment variable in javascript web code

Posted on 2004-04-20
Medium Priority
Last Modified: 2007-12-19

does anyone know how to read an environment variable into a javascript running in a html page?

I would like to take appropriate action in the web page based on a particular environment variable....

Question by:sbradley2002
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 35

Expert Comment

by:[ fanpages ]
ID: 10875725
Hi sbradley2002,

Local (workstation) environment variable, or one defined on the (Windows?) web server?



Author Comment

ID: 10875732

sorry didn't say,
I want it to read the variable from the client machine.
I should say that this web page is only being run as a web desktop on windows xp pro machines in my organisation, not actually being published anywhere

LVL 35

Expert Comment

by:[ fanpages ]
ID: 10875842

I'm fairly certain that you cannot do this directly in HTML/Javascript alone.

You would need a scripting language such as Perl, CGI, PHP, VBScript etc on your client machine, or a Java applet.

Could you not use cookies instead?  And during installation of the client machines set the cookies to the initial values as defined in your DOS environment variables?

Or, maybe you could invoke the .htm(l) page with query parameters (?path=<...>&comspec=<...>) set by an external process (e.g. a Visual Basic .exe) that could read the environment variables in advance.




Author Comment

ID: 10875880
whatever works....
Would u know how to set up these cookies - or where I can find this info?
Can they be setup each time a user logs in on the machine?
LVL 35

Accepted Solution

[ fanpages ] earned 400 total points
ID: 10876056
The cookies would need to be set by a server-based process, that yes, could be invoked during log-on to the machine (if the machines are connected to a central server).

The server process would be called, query the environment variables of the connected workstation (maybe just a simply "set" command to a temporary file that is read on the server and cookie creation directly based on the contents of the file), and return to the log-in procedure.

Your client-side javascript should then query the cookies & act accordingly.

I don't know of any URLs off-hand.

Maybe just "google" for them?




Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

777 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