Use of javascript/Jscript at Win32 DOS prompt

D

Dr John Stockton

The following DOS prompt command line, in a Win98 DOS box,

cscript //nologo ~tmp.js

executes file ~tmp.js as javascript/Jscript.


The following batch file, similarly run, executes the same.

@echo off
echo WScript.Echo(new Date().toUTCString()); > ~tmp.js
cscript //nologo ~tmp.js | STOW GMT
del ~tmp.js

( STOW is a program of mine; the (first line of the) standard output of
cscript is stored in environment variable GMT, in DOS..Win98/ME but
not NT-type systems. )


Such scripts are presumably on-topic here. They will differ from Web-
type scripts in the matter of I/O and controls. They add features to
batch file use, because javascript can do much more than pure Batch; it
can, for example, get GMT.


(a) ISTM worth mentioning this in the FAQ, as it opens a door that might
not previously have been noticed and which has much on the other side.

(b) What is there to say about differences of DOM-type? Differences in
I/O? Use of wscript?

(c) Are any good references known, dealing with the above and not too
much else?
 
M

Martin Honnen

Dr said:
The following DOS prompt command line, in a Win98 DOS box,

cscript //nologo ~tmp.js

executes file ~tmp.js as javascript/Jscript.

You do not even need the command line, double clicking the file should
run it with wscript.
And of course Windows Script Host for some years now also has some XML
format for .wsf files which allow you to include different library files
etc.
Such scripts are presumably on-topic here.

I don't mind anyone asking questions about JScript programs for Windows
Script Host here but I think that groups like
microsoft.public.scripting.wsh
provide more expertise on Windows Script host. Admittedly WSH groups
postings are more often dealing with VBScript programming than JScript
programming but the object model is the same. And there are jscript
scripting groups on the Microsoft server that deal with Windows Script
Host programming too.

(a) ISTM worth mentioning this in the FAQ, as it opens a door that might
not previously have been noticed and which has much on the other side.

Windows Script Host is mentioned in the FAQ as one of the common hosts.
The HTML version of the FAQ is even created by a .wsf file.

(c) Are any good references known, dealing with the above and not too
much else?

Well, the MS scripting documentation documents the Windows Script Host
object model, file format etc:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp

Of course that is not all that is possible, once you are outside of the
security restrictions of the browser you can instantiate everything from
ADODB objects for doing data base stuff to Word.Application and script it.
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
You do not even need the command line, double clicking the file should
run it with wscript.

Not when working at a DOS prompt. I had in mind including that in a DOS
batch file, as I showed below.

And of course Windows Script Host for some years now also has some XML
format for .wsf files which allow you to include different library files
etc.


I don't mind anyone asking questions about JScript programs for Windows
Script Host here but I think that groups like
microsoft.public.scripting.wsh
provide more expertise on Windows Script host. Admittedly WSH groups
postings are more often dealing with VBScript programming than JScript
programming but the object model is the same. And there are jscript
scripting groups on the Microsoft server that deal with Windows Script
Host programming too.

AFAICS, they in practice refer at least predominantly and AFAIR almost
wholly to VBscript (when using WSH) or to use in Web pages.

Windows Script Host is mentioned in the FAQ as one of the common hosts.
The HTML version of the FAQ is even created by a .wsf file.

Mentioned rather in passing, though, and unlikely to be noticed by the
unaware.

Well, the MS scripting documentation documents the Windows Script Host
object model, file format etc:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp

MS references are rarely good for those with an intermittent Net
connection. They have rather few information bits per byte transferred.


I believe that an entry in Section 4 of the FAQ would be worthwhile;
just illustrating starting javascript-in-WSH from the command line and
from, say, File Manager & Internet Explorer, and giving a well-chosen
link or two.

It could include
<script type="text/javascript" src="include1.js"></script>
&
<script type="text/javascript">
...
</script><noscript> ... </noscript>
- they may be strictly HTML, but they are important to Web use of
javascript, and often given wrongly in the group.

Perhaps a possible <FAQENTRY> could be composed here, if Jim would like
to use such.




The FAQ has not been updated lately, and new expertise has come into the
group. Might it be worth jointly reviewing one numbered part here each
week, starting I suggest at 3.1 and working round to 2.12 then 3.1
again?

Re 3.1 - I find the Pocket Reference Flanagan very useful; it is cheaper
& smaller.

Re 3.2 - Nothing to say about the intent, but I'd prefer <p> instead of
<BR> before each subsubsection.
 
M

Martin Honnen

Dr said:
JRS: In article <[email protected]>, seen in
Martin Honnen <[email protected]> posted at
Sun, 21 Dec 2003 19:41:43 :-




MS references are rarely good for those with an intermittent Net
connection. They have rather few information bits per byte transferred.

You can download the docs at the posted link, no need to visit them online.
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
Also from the FAQ, and not worth duplicating the info of:

Sites focused on using Scripting to automate Windows:
http://www.windows-script.com/
http://cwashington.netreach.net/

Although it may be worth while altering the text along with those
urls.

Thanks, I will look at those. Yes, the words could be changed; much of
the time, I consider Windows as merely an environment for running
several DOS boxes in and for providing better-looking editors.

Presuming applicable, something with the words MSDOS & Batch might be
added?
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
JRS: In article <[email protected]>, seen in


Thanks, I will look at those. Yes, the words could be changed; much of
the time, I consider Windows as merely an environment for running
several DOS boxes in and for providing better-looking editors.

Presuming applicable, something with the words MSDOS & Batch might be
added?

One is a Microsoft site, (now?) masquerading under a false identity; the
other is a sort of newsgroup, and very slow. Neither is what I would
like to find under that heading, although it is certainly a valid
description of that pair.
 
T

Thomas 'PointedEars' Lahn

Martin said:
Dr said:
[...] Martin Honnen said:
Well, the MS scripting documentation documents the Windows Script Host
object model, file format etc:
http://msdn.microsoft.com/library/default.asp?url=/downloads/list/webdev.asp

MS references are rarely good for those with an intermittent Net
connection. They have rather few information bits per byte transferred.

You can download the docs at the posted link,

Alas, you cannot.

| Microsoft Windows Script 5.6 Documentation
|
<http://www.microsoft.com/downloads/...48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en>
| This download provides extensive reference and conceptual
| documentation for all of Microsoft Windows Script Technologies.
| Date: September 12, 2001

Following the link results in:

| RTSP/1.0 400 Bad Request
| Server: QTSS-Akamai/4.1 (Build/412.16; Platform/Linux)
| Cseq:
| Connection: Close

Reproducible.
no need to visit them online.

I would be glad if it were the case.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top