1

I'm trying to open 2 applications with a VBScript file and make them split screen. I was following this code below but it's only getting me to the file location and not actually launching it.

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
'*****************************************************
Community
  • 1
  • 1
doppis
  • 11
  • 3

1 Answers1

0

The script does exactly what you tell it to do: open two Explorer windows with the locations of the two programs. That is what explorer /n,/select,... does. If you want to run the programs instead of opening their location you need to, well, actually run the programs:

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

The double quotes are there to avoid issues with spaces in a path.

As a side note: it's pointless to have a function return something when you're never using that return value anyway. Just make it a Sub instead.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328