wscript和cscript之间的区别 [英] Difference between wscript and cscript

查看:299
本文介绍了wscript和cscript之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

cscript和wscript有什么区别?在Windows中执行Telnet和FTP自动化最好?

解决方案

在Windows中,可执行文件是控制台应用程序或Windows应用程序(或SFU或本机应用程序,但这并不重要)。



内核检查可执行文件中的标志以确定哪个标志。



开始使用 CreateProcess WinAPI函数时,如果它是一个控制台应用程序,内核将为它创建一个控制台窗口没有一个,并附上 STDIN STDOUT STDERR

如果它是Windows应用程序,则不会创建控制台,并且 STDIN STDOUT STDERR 会被默认关闭。



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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆