Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
120
rated 0 times [  127] [ 7]  / answers: 1 / hits: 33604  / 16 Years ago, thu, march 26, 2009, 12:00:00

I'm trying to run javascript from a windows command line via script



cscript //NoLogo test.js



However, I can't find any predefined objects which are available. I'm totally at a loss - Can't get hello world to work:



System.print(Hello, World!)



results in System is undefined



Is there another way I should be running this - like through .NET runtime?



Thanks



jeff


More From » windows

 Answers
13

You are using the Windows Scripting Host.



You can say things like:



WScript.Echo(Hello, World.);


It's all COM-based, so you instantiate ActiveX controls to do anything useful:



var y = new ActiveXObject(Scripting.Dictionary);
y.add (a, test);
if (y.Exists(a))
WScript.Echo(true);


Or:



var fso, f1;
fso = new ActiveXObject(Scripting.FileSystemObject);
// Get a File object to query.
f1 = fso.GetFile(c:\detlog.txt);
// Print information.
Response.Write(File last modified: + f1.DateLastModified);


See Windows Script Host.


[#99792] Friday, March 20, 2009, 16 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jenamackennac

Total Points: 304
Total Questions: 110
Total Answers: 107

Location: Ecuador
Member since Thu, Jun 4, 2020
4 Years ago
jenamackennac questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Wed, Apr 21, 21, 00:00, 3 Years ago
Thu, Apr 1, 21, 00:00, 3 Years ago
Tue, Feb 2, 21, 00:00, 3 Years ago
;