如何在分屏中打开2个应用程序?

时间:2016-01-05 03:17:28

标签: windows vbscript

我正在尝试使用VBScript文件打开2个应用程序并将其分割为屏幕。我正在关注下面的this code,但它只是让我到文件位置而不是实际启动它。

Option Explicit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Launches two Explorer windows side-by-side filling the screen dimensions.
''' Minimizes all current open windows before launch; if this is not done,
''' the current open windows will also be resized along with our two windows.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim Calc,objShell
Calc = "%windir%\system32\calc.exe"
Set objShell = CreateObject("Shell.Application")

objShell.MinimizeAll
Call Explore(Calc)
WScript.Sleep 800
Call Explore(Calc)
WScript.Sleep 800
objShell.TileVertically
Set objShell = Nothing

'*****************************************************
Function Explore(Path)
  Dim ws
  Set ws = CreateObject("WScript.Shell")
  Explore = ws.run("Explorer /n,/select,"& Path &"")
End Function
'*****************************************************

1 个答案:

答案 0 :(得分:0)

该脚本完全按照您的要求执行操作:打开两个Explorer窗口,其中包含两个程序的位置。这就是explorer /n,/select,...的作用。如果你想运行程序而不是打开它们的位置,你需要实际运行程序:

ws.run """" & Path & """"

双引号用于避免路径中的空格问题。

作为旁注:当你从不使用那个返回值时,让函数返回一些东西是没有意义的。只需改为Sub