wscript和cscript的区别 [英] Difference between wscript and cscript
问题描述
cscript 和 wscript 有什么区别?哪个最适合在 Windows 中进行 Telnet 和 FTP 自动化?
在 Windows 中,可执行文件是控制台应用程序或 Windows 应用程序(或 SFU 或本机应用程序,但这并不重要).
内核检查可执行文件中的标志以确定哪个.
开始使用CreateProcess
WinAPI函数时,如果是控制台应用程序,如果父进程没有,内核会为其创建一个控制台窗口,并附加STDIN
、STDOUT
和 STDERR
流到控制台.
如果是Windows应用程序,不会创建控制台,默认关闭STDIN
、STDOUT
和STDERR
.p>
WSCRIPT.EXE
和 CSCRIPT.EXE
几乎完全相同,只是一个被标记为 Windows 应用程序,另一个被标记为控制台应用程序(猜猜哪个绕路!).
所以答案是:如果您希望您的脚本有一个控制台窗口,请使用 CSCRIPT.EXE
.如果您希望它没有控制台窗口,请使用 WSCRIPT.EXE
.
这也会影响一些行为,例如 WScript.Echo 命令.在 CSCRIPT.EXE
中,这会将一行写入控制台窗口.在 WSCRIPT.EXE
中显示一个消息框.
对于您的应用程序,我建议使用 CSCRIPT.EXE
.我认为你也应该看看 PuTTY 和 PLink,你也应该在这里看到这个:
What is the difference between cscript and wscript? Which is best for doing Telnet and FTP automation in Windows?
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:
这篇关于wscript和cscript的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!