473,659 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving Environment Variables

Is there a way to retrieve the Windows Environment Variables (Such as
User ID) with Javascript in IE?

Jan 3 '06 #1
6 16280
Matt wrote on 03 jan 2006 in comp.lang.javas cript:
Is there a way to retrieve the Windows Environment Variables (Such as
User ID) with Javascript in IE?


That would be a security risk, so: No, not in a default setting.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 3 '06 #2
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Tue, 3
Jan 2006 20:46:48 local, seen in news:comp.lang. javascript, Evertjan.
<ex************ **@interxnl.net > posted :
Matt wrote on 03 jan 2006 in comp.lang.javas cript:
Is there a way to retrieve the Windows Environment Variables (Such as
User ID) with Javascript in IE?


That would be a security risk, so: No, not in a default setting.


It's not necessarily a security risk if the IE is displaying a local
page rather than one obtained from outside (the latter is our default
assumption here).

Javascript running under WSH can read environment variables - see in
<URL:http://www.merlyn.demo n.co.uk/batfiles.htm#WS H> - and AIUI the
script engine is shared with IE. So it's conceivable that the OP's
question might be answerable in the affirmative - but I don't know how
to do it.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk DOS 3.3, 6.20; Win98. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demo n.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demo n.co.uk/batfiles.htm> - also batprogs.htm.
Jan 4 '06 #3
Dr John Stockton wrote on 04 jan 2006 in comp.lang.javas cript:
Javascript running under WSH can read environment variables - see in
<URL:http://www.merlyn.demo n.co.uk/batfiles.htm#WS H> - and AIUI the
script engine is shared with IE. So it's conceivable that the OP's
question might be answerable in the affirmative - but I don't know how
to do it.


The below is VBS but can be easily translated to wscript-JS:

======== showEnvVar.vbs ===========

set WshShell = CreateObject("W Script.Shell")

set oEnv=WshShell.E nvironment("Sys tem")
for each sitem in oEnv
strval=strval & sItem &vbcrlf
next
wscript.echo "System Environment:"&v bcrlf&vbcrlf&st rval
strval=""

'//Process Type
set oEnv=WshShell.E nvironment("Pro cess")
for each sitem in oEnv
strval=strval & sItem &vbcrlf
next
wscript.echo "Process Environment:"&v bcrlf&vbcrlf&st rval
strval=""

'//User Type
set oEnv=WshShell.E nvironment("Use r")
for each sitem in oEnv
strval=strval & sItem &vbcrlf
next
wscript.echo "User Environment:"&v bcrlf&vbcrlf&st rval
strval=""

'//Volatile Type
set oEnv=WshShell.E nvironment("Vol atile")
for each sitem in oEnv
strval=strval & sItem &vbcrlf
next

wscript.echo "Volatile Environment:"&v bcrlf&vbcrlf&st rval
strval=""

=============== =============== =====

Source: <http://hacks.oreilly.c om/pub/h/1107>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 4 '06 #4
Dr John Stockton said the following on 1/4/2006 12:25 PM:
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Tue, 3
Jan 2006 20:46:48 local, seen in news:comp.lang. javascript, Evertjan.
<ex************ **@interxnl.net > posted :
Matt wrote on 03 jan 2006 in comp.lang.javas cript:

Is there a way to retrieve the Windows Environment Variables (Such as
User ID) with Javascript in IE?


That would be a security risk, so: No, not in a default setting.

It's not necessarily a security risk if the IE is displaying a local
page rather than one obtained from outside (the latter is our default
assumption here).

Javascript running under WSH


Except that Javascript doesn't "run under WSH". JScript does though.

People who live in glass houses shouldn't throw stones at the neighbors.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 4 '06 #5
Randy Webb wrote on 04 jan 2006 in comp.lang.javas cript:
Dr John Stockton said the following on 1/4/2006 12:25 PM:
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Tue, 3
Jan 2006 20:46:48 local, seen in news:comp.lang. javascript, Evertjan.
<ex************ **@interxnl.net > posted :
Matt wrote on 03 jan 2006 in comp.lang.javas cript:
Is there a way to retrieve the Windows Environment Variables (Such as
User ID) with Javascript in IE?
That would be a security risk, so: No, not in a default setting.

It's not necessarily a security risk if the IE is displaying a local
page rather than one obtained from outside (the latter is our default
assumption here).

Javascript running under WSH


Except that Javascript doesn't "run under WSH". JScript does though.

People who live in glass houses shouldn't throw stones at the neighbors.


Why not? It would be fun.

Let's meet at Christal Palace, John!

[Or did you hit it in 1854?]

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 4 '06 #6
JRS: In article <Xn************ ********@194.10 9.133.242>, dated Wed, 4
Jan 2006 18:41:19 local, seen in news:comp.lang. javascript, Evertjan.
<ex************ **@interxnl.net > posted :
Dr John Stockton wrote on 04 jan 2006 in comp.lang.javas cript:
Javascript running under WSH can read environment variables - see in
<URL:http://www.merlyn.demo n.co.uk/batfiles.htm#WS H> - and AIUI the
script engine is shared with IE. So it's conceivable that the OP's
question might be answerable in the affirmative - but I don't know how
to do it.


The below is VBS but can be easily translated to wscript-JS:

======== showEnvVar.vbs ===========

I have, at the cited reference, javascript that executed by cscript
(console version of wscript); it does not look equivalent, but simpler.

However, the question of whether such code can be executed successfully
from a local file by javascript in IE remains open.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/> JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jan 5 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
7406
by: Artco News | last post by:
How to get Windows XP Server(where PHP Server is running) environment variables? I use the echo $_ENV seem to not working. The same for any other environment variables. I'm running PHP-4.3.4 version with Apache 2.0.48. Thanks
3
2224
by: Greg Lindstrom | last post by:
Hello- I am running python 2.3. on an HP-9000 box running Unix and have a POSIX script that sets up my production environment. I would like to run the script from inside a python routine and pick up the environment variables but am having trouble getting it done. Suppose the script is called setprod. How can I call this from inside a python script then pick up the env's later in my program? I've tried os.system ('setprod') and...
1
2837
by: Shahzad Atta | last post by:
Hi there, I am using a batch file to do some zipping task. This batch file get executed on postbuild event which I set through project properties. Now when I execute the batch file from command prompt (System Or Visual Studio.Net) I get the desired behavior. But when I Build the project I am not getting the desired result. The batch file includes a if statement which checks an environment variable and takes the desired action the...
4
12864
by: Ron Clarke | last post by:
I have an application that starts other processes. The app needs to create/set a few environment variables when a process starts, let the process run, then remove the environment variables when the process terminates. Looking through the C# and .NET docs, I've found how to get environment variables, but not how to create and set them. I found the EnvironmentPermissions class which grants access, but that's not enough. Can anyone help me...
1
2016
by: pagates | last post by:
Hi All, What's the "best" way to get System Environment Variables (VS2003)? Environment.GetEnvironmentVariable("xxx") only gets user Environment variables. Thanks, pagates
2
1732
by: ANarula | last post by:
I am running into a strange problem. I have perl script which reads the "APPDATA" environment variable, and does some work on that directory. When I a launch this script from Command Prompt, it works perfectly fine, however when the same script is launched from a DLL hosted in a particular Service, the script fails to read the envrionment variable. Does any one has any clue, whats going wrong ? Regards,
3
3747
by: Tristan | last post by:
Hello community: I post this because I could not find satisfactory answers in the posts generated by this nice group. I work on winXP. I have many little python applications in different folders, each application can share or not other objects located in the same or other folders. The way I work to use these applications is: 1) For almost everyone, I execute a corresponding ".bat file" into
2
2891
by: Thierry Lam | last post by:
I'm using the WMI library for python and I was able to connect to another computer on the network with the following line: c = wmi.WMI(computer="the-network-computer", user="hello", password="hello") Is there a way to write information to a file on that computer? How do I read environment variables, for example SystemDrive?
3
2001
by: smitty1e | last post by:
Just a fun exercise to unify some of the major input methods for a script into a single dictionary. Here is the output, given a gr.conf file in the same directory with the contents stated below: smitty@localhost ~/proj/mddl4/test $ ./inputs.py {'source_db': '/home/sweet/home.db'} smitty@localhost ~/proj/mddl4/test $ source_db="test_env" ./inputs.py {'source_db': 'test_env'} smitty@localhost ~/proj/mddl4/test $ ./inputs.py -f "test_cli"
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.