Difference between wscript and cscript
Asked Answered
A

1

93

What is the difference between cscript and wscript? Which is best for doing Telnet and FTP automation in Windows?

Audra answered 30/12, 2011 at 10:21 Comment(0)
P
138

In Windows, an executable is either a console application or a Windows application (or a SFU or Native application, but that doesn't matter here).

The kernel checks a flag in the executable to determine which.

When starting using CreateProcess WinAPI function, if it is a console application, the kernel will create a console window for it if the parent process doesn't have one, and attach the STDIN, STDOUT and STDERR streams to the console.

If it is a Windows application, no console will be created and STDIN, STDOUT and STDERR will be closed by default.

WSCRIPT.EXE and CSCRIPT.EXE are almost exactly identical, except that one is flagged as a windows application and the other is flagged as a console application (Guess which way around!).

So the answer is: If you want your script to have a console window, use CSCRIPT.EXE. If you want it to NOT have a console window, use WSCRIPT.EXE.

This also affects some behaviors, such as the WScript.Echo command. In a CSCRIPT.EXE this writes a line to the console window. In WSCRIPT.EXE it shows a messagebox.

For your application I suggest CSCRIPT.EXE. I think you should also look at PuTTY and PLink, and you should also see this here:

Pruett answered 30/1, 2012 at 10:56 Comment(2)
@McDonald's I'm just trying to make a living. I have no real choice but to use Stack Overflow as there is no alternative, and I detest the way the owners keep using the site to make political points about whatever is making it hard to digest their breakfast that month. So my username is my protest against that sort of politicisation of every damned thing.Pruett
Simple and clear cut for people like me who don't know any basics tooRelent

© 2022 - 2024 — McMap. All rights reserved.