Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

get environment variable in javascript web code

Posted on 2004-04-20
7
Medium Priority
?
859 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
[X]
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
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 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?

BFN,

fp.

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
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.
Six Sigma Control Plans
Progress

618 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