Solved

get environment variable in javascript web code

Posted on 2004-04-20
7
829 Views
Last Modified: 2007-12-19
Hello,

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....

thx,
Shaun
0
Comment
Question by:sbradley2002
  • 3
  • 2
7 Comments
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 10875725
Hi sbradley2002,

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

BFN,

fp.
0
 

Author Comment

by:sbradley2002
ID: 10875732
fanpages,

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

thx,
0
 
LVL 35

Expert Comment

by:[ fanpages ]
ID: 10875842
Hi,

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.

Sorry...

BFN,

fp.
0
 

Author Comment

by:sbradley2002
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?
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 100 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?

BFN,

fp.

0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

773 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