这里的两个参数对于 WScript 意味着什么?

发布于 2024-08-25 02:47:49 字数 257 浏览 1 评论 0原文

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($cmd, 0, false);

我似乎没有找到这方面的文档...

编辑

是否需要一些设置来启用它?我发现上面的脚本不起作用是否将第二个参数设置为true< /code> 或 false

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run($cmd, 0, false);

I don't seem to find the document for this...

EDIT

Does it need some settings to enable it?I found the above script is not working whether setting the second parameter to true or false

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

过度放纵 2024-09-01 02:47:49
Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 
  • WindowStyle = 0 表示“隐藏窗口并激活另一个窗口”。
  • WaitOnReturn = false 表示“Run 方法在启动程序后立即返回,自动返回 0(不被解释为错误代码)”。

运行方法的完整文档在这里:
http://msdn.microsoft.com/en-我们/库/d5fk67ky%28VS.85%29.aspx

Run(strCommand, [intWindowStyle], [bWaitOnReturn]) 
  • WindowStyle = 0 means "Hides the window and activates another window."
  • WaitOnReturn = false means "the Run method returns immediately after starting the program, automatically returning 0 (not to be interpreted as an error code)."

The full documentation for the Run Method is here:
http://msdn.microsoft.com/en-us/library/d5fk67ky%28VS.85%29.aspx

ヤ经典坏疍 2024-09-01 02:47:49

有关完整详细信息,请参阅此处Run 的第二个参数是窗口样式(最小化、最大化等),第三个参数是是否等待程序完成后再继续。第一个当然是要运行的程序。


并复制此处的信息以使答案独立:

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])

对象 - WshShell 对象。
strCommand - 指示要运行的命令行的字符串值。您必须包含要传递给可执行文件的任何参数。
intWindowStyle - 可选。指示程序窗口外观的整数值。请注意,并非所有程序都使用此信息。
bWaitOnReturn - 可选。布尔值,指示脚本是否应等待程序完成执行,然后再继续执行脚本中的下一条语句。如果设置为 true,脚本执行将暂停,直到程序完成,并且 Run 返回程序返回的任何错误代码。如果设置为 false(默认值),则 Run 方法在启动程序后立即返回,自动返回 0(不被解释为错误代码)。

窗口样式有:

 0   Hides the window and activates another window.
 1   Activates and displays a window. If the window is minimized or maximized,
     the system restores it to its original size and position. An application
     should specify this flag when displaying the window for the first time.
 2   Activates the window and displays it as a minimized window.
 3   Activates the window and displays it as a maximized window.
 4   Displays a window in its most recent size and position. The active window
     remains active.
 5   Activates the window and displays it in its current size and position.
 6   Minimizes the specified window and activates the next top-level window in
     the Z order.
 7   Displays the window as a minimized window. The active window remains active.
 8   Displays the window in its current state. The active window remains active.
 9   Activates and displays the window. If the window is minimized or maximized,
     the system restores it to its original size and position. An application
     should specify this flag when restoring a minimized window.
10   Sets the show-state based on the state of the program that started the
     application.

See here for full details. The second argument to Run is the window style (minimised, maximised, etc) and the third is whether to wait for the program to complete before continuing. The first is, of course, the program to run.


And copying the information here to make the answer self-contained:

object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])

object - WshShell object.
strCommand - String value indicating the command line you want to run. You must include any parameters you want to pass to the executable file.
intWindowStyle - Optional. Integer value indicating the appearance of the program's window. Note that not all programs make use of this information.
bWaitOnReturn - Optional. Boolean value indicating whether the script should wait for the program to finish executing before continuing to the next statement in your script. If set to true, script execution halts until the program finishes, and Run returns any error code returned by the program. If set to false (the default), the Run method returns immediately after starting the program, automatically returning 0 (not to be interpreted as an error code).

The window styles are:

 0   Hides the window and activates another window.
 1   Activates and displays a window. If the window is minimized or maximized,
     the system restores it to its original size and position. An application
     should specify this flag when displaying the window for the first time.
 2   Activates the window and displays it as a minimized window.
 3   Activates the window and displays it as a maximized window.
 4   Displays a window in its most recent size and position. The active window
     remains active.
 5   Activates the window and displays it in its current size and position.
 6   Minimizes the specified window and activates the next top-level window in
     the Z order.
 7   Displays the window as a minimized window. The active window remains active.
 8   Displays the window in its current state. The active window remains active.
 9   Activates and displays the window. If the window is minimized or maximized,
     the system restores it to its original size and position. An application
     should specify this flag when restoring a minimized window.
10   Sets the show-state based on the state of the program that started the
     application.
花之痕靓丽 2024-09-01 02:47:49

引用上面的参考文献:

strCommand 表示命令的字符串值
您要运行的命令行。你必须
包括您想要的任何参数
传递给可执行文件。

intWindowStyle 可选。整数值
表示外观
程序的窗口。请注意,并非所有
程序利用此信息。

bWaitOnReturn 可选。布尔值
指示脚本是否应该
等待程序完成
在继续之前执行
脚本中的下一条语句。如果设置
设置为 true 时,脚本执行将停止,直到
程序完成,Run 返回
返回的任何错误代码
程序。如果设置为 false(
默认),Run 方法返回
启动后立即
程序,自动返回0
(不应被解释为错误
代码)。

To quote from the above reference:

strCommand String value indicating the
command line you want to run. You must
include any parameters you want to
pass to the executable file.

intWindowStyle Optional. Integer value
indicating the appearance of the
program's window. Note that not all
programs make use of this information.

bWaitOnReturn Optional. Boolean value
indicating whether the script should
wait for the program to finish
executing before continuing to the
next statement in your script. If set
to true, script execution halts until
the program finishes, and Run returns
any error code returned by the
program. If set to false (the
default), the Run method returns
immediately after starting the
program, automatically returning 0
(not to be interpreted as an error
code).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文