Vbscript 如何使用vbs在所有其他正在运行的程序之后运行程序?

Vbscript 如何使用vbs在所有其他正在运行的程序之后运行程序?,vbscript,Vbscript,这段代码非常有效。它将在chrome选项卡中打开站点: Set WshShell = WScript.CreateObject("WScript.Shell") Return = WshShell.Run("chrome.exe stackoverflow.com " & WScript.ScriptFullName, 0, false) 但是,是否可以在所有其他正在运行的程序后面打开相同的浏览器选项卡 我的意思是说。Chrome选项卡位于exel窗口后面。来自帮助 在新进程中运行程序

这段代码非常有效。它将在chrome选项卡中打开站点:

Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("chrome.exe stackoverflow.com " & WScript.ScriptFullName, 0, false)
但是,是否可以在所有其他正在运行的程序后面打开相同的浏览器选项卡

我的意思是说。Chrome选项卡位于exel窗口后面。

来自帮助

在新进程中运行程序

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

对象
WshShell
object

strCommand字符串值,指示要运行的命令行。必须包括要传递给 可执行文件

IntWindowsStyle

可选。整数值,指示程序的 窗户。请注意,并非所有程序都使用此信息

bWaitOnReturn

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

备注

Run方法返回一个整数。Run方法启动一个程序 在新的Windows进程中运行。您可以让脚本等待 要在继续之前完成执行的程序。这允许您 同步运行脚本和程序。内部环境变量 参数
strCommand
将自动展开。如果文件类型为 已正确注册到特定程序,调用 该类型的文件执行程序。例如,如果单词是 安装在计算机系统上,调用*.doc文件上的运行将启动 Word并加载文档。下表列出了可用的
intWindowStyle
的设置

IntWindowsStyle说明

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.
以下VBScript代码打开当前正在运行的 带记事本的脚本

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "%windir%\notepad " & WScript.ScriptFullName
下面的VBScript代码除了指定 窗口类型,等待用户关闭记事本,然后 保存记事本关闭时返回的错误代码

Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run("notepad " & WScript.ScriptFullName, 1, true)
以下VBScript代码打开命令窗口,更改为 指向C:\,并执行DIR命令

Dim oShell
Set oShell = WScript.CreateObject ("WSCript.shell")
oShell.run "cmd /K CD C:\ & Dir"
Set oShell = Nothing
适用于:

WshShell Object

对于第二个问题,您需要将程序和路径用双引号括起来:
Return=WshShell.Run(““C:\program Files(x86)\Google\Chrome\Application\Chrome.exe”“stackoverflow.com”&WScript.ScriptFullName,0,false)
什么是“behind”?我在帖子中添加了“隐藏”的例子,或者是“在窗户的下半部分”@Nathan Rice。