Matthew Lewis
Matthew Lewis

Reputation: 3

VB Script to open multiple programs at once

Right im looking for a script that I can click on after I have logged in to open various programs just to save me a bit of time. I have managed to get a script to open one but as a bit of a newbie can someone provide advice.

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run """C:\Program Files (x86)\servicecenter\Run\scguiw32.exe "" ""-

express:dvla.servicecenter.fs.fujitsu.com.12680"""
Set objShell = Nothing

Upvotes: 0

Views: 12469

Answers (4)

Ren Shino
Ren Shino

Reputation: 11

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run("Path to program")
wscript.sleep (100)
objShell.Run("Path to program")
wscript.sleep (100)
wscript.quit

Upvotes: 1

FTBC
FTBC

Reputation: 11

You might be overthinking it a bit to use VBScript or Powershell for this job. A batch file will work.

@echo off
start "c:\Program Files\Folder 1\program.exe"
start "c:\Program Files\Folder 2\program.exe" -switch -argument
exit

Upvotes: 1

J P
J P

Reputation: 321

Here is how to use vbscript to create an array of programs you want to run and then execute each one.

'---Declare Variables
Dim objShell, strprogram1, strProgram2, colprograms, item

'---Create Scripting Shell Object
Set objShell = CreateObject("WScript.Shell")

'---Create Program Variables
strProgram1 = """C:\Program Files (x86)\servicecenter\Run\scguiw32.exe"" ""-express:dvla.servicecenter.fs.fujitsu.com.12680"""
strProgram2 = "C:\Windows\notepad.exe C:\Dump.txt"

'---Add Variables to an Array
colPrograms = Array(strProgram1,strProgram2)

'---Run each program in the array once
For Each item In colprograms
    objShell.Run item
Next

WScript.Echo "Done."

Upvotes: 0

Piotr Stapp
Piotr Stapp

Reputation: 19830

I do not have scguiw32.exe, so I created simple script which opens file in notepad and in word.

Dim objShell
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run "C:\Windows\notepad.exe c:\dump.txt"

objShell.Run """C:\Program Files (x86)\Microsoft Office\Office14\winword.exe"" c:\dump.txt"
Set objShell = Nothing

BTW Instead of vbscript you can use now powershell, and powershell script is much more easy to understand. For example above one will be: Create run.ps1 with content

& 'C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE' c:\dump.txt
notepad.exe C:\dump.txt

Click it right-click and choose Run with Powershell

Upvotes: 0

Related Questions