Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between wscript and cscript

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

like image 235
rashok Avatar asked Dec 30 '11 10:12

rashok


People also ask

What is a cscript?

Cscript.exe is a command-line version of the Windows Script Host that provides command-line options for setting script properties. With Cscript.exe, you can run scripts by typing the name of a script file at the command prompt.

What is wscript used for?

The genuine wscript.exe file is a software component of Microsoft Windows by Microsoft. Windows is an operating system. Windows Script host is a service that provides scripting abilities for Windows operating systems. Wscript.exe is tasked with executing the VBScript files, and does not cause any harm to your PC.

What is C Windows system32 cscript?

Cscript.exe is essentially the command-line version of the Windows Script Host service and facilitates command-line options for setting up script properties. With Cscript.exe, scripts can be run automatically or by simply typing the name of the script file inside the command prompt.


1 Answers

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:

  • Capturing output from WshShell.Exec using Windows Script Host
like image 196
Ben Avatar answered Sep 28 '22 10:09

Ben