Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Environment Variables in WSH JS

Reply
Thread Tools

Environment Variables in WSH JS

 
 
Dr John Stockton
Guest
Posts: n/a
 
      01-06-2004

In javascript executed by Windows Scripting Host, one can input via
command-line parameters : File $95.js :-
x = WScript.Arguments
WScript.echo("Result:", x.length, typeof x, x[1], "OK")

Prompt>cscript //nologo $95.js 66 77 88
Result: 3 object 77 OK
The Arguments are 0-based.

Can one read/write Environment variables, and if so how? An answer for
VBscript could be useful, as well or in lieu.


Aside : <FAQENTRY> 2.11 : "over 5 years" is IMHO ambiguous. Suggest
"more than 5 years" or "for 5 years", whichever is meant.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20; Win98.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.
 
Reply With Quote
 
 
 
 
Yann-Erwan Perio
Guest
Posts: n/a
 
      01-06-2004
Dr John Stockton wrote:

> Can one read/write Environment variables, and if so how? An answer for
> VBscript could be useful, as well or in lieu.


Use the WshShell object to read the Environment property:

---
var ws, en, buf;

ws=WScript.CreateObject("WScript.Shell");
en=new Enumerator(ws.Environment)
buf=[];

for(;!en.atEnd();en.moveNext())
buf.push(en.item());

WScript.Echo(buf.join("\n"));
ws=null;
---

Reference:<URL:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsProEnvironment.asp>
Download:<URL:http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp>


HTH
Yep.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't see the arguements when use Python in WSH. GaryLee Python 2 09-17-2007 06:04 AM
Can IronPython work as Windows Scripting Host (WSH) language? misiek3d Python 1 06-28-2007 08:14 PM
wsh and Python David Josty Python 1 04-09-2005 11:55 PM
IISFAQ WSH Script in/to DotNet Benjamin Bittner ASP .Net 6 06-28-2004 03:21 PM
lost in ASP & WSH!please help! kyiu ASP General 1 07-11-2003 03:28 PM



Advertisments