Reputation: 2453
I have a vb script that starts an exe (or even a process without gui):
strCom = "Start calc"
WSHShell.Run(strCom)
It doesn't start the program, when I open task manager I can't see it.
But when I write the command "Start calc" directly in the command line it opens it.
How can I do it using the script?
Upvotes: 6
Views: 34398
Reputation: 21
CreateObject("WScript.Shell").Run("**Application**")
I don't plan on making video for this script in action. Though I did make a cool error game with it.
Upvotes: 1
Reputation:
Starting a system process like calc.exe or cmd.exe
code
Dim shl
Set shl = CreateObject("Wscript.Shell")
Call shl.Run("""calc.exe""")
Set shl = Nothing
WScript.Quit
Starting a normal process
code
Dim shl
Set shl = CreateObject("Wscript.Shell")
Call shl.Run("""D:\testvbs\someServices.exe""")
Set shl = Nothing
WScript.Quit
You can launch any batch file too using VBscript. just provide the path of batch file in shl.run() while calling it.
Upvotes: 4
Reputation: 38775
Or/In addition - if using start
is important:
CreateObject("WScript.Shell").Run "%comspec% /c start /wait notepad.exe", 0, True
CreateObject("WScript.Shell").Exec "%comspec% /c start E:\Handapparat\Algorithms\diktaat.pdf"
resp. some variations thereof.
Upvotes: 2
Reputation: 888223
start
is built-in to cmd.exe
; it's not an actual program.
WSHShell.Run
takes a physical file , not a cmd
built-in.
Therefore, you can write WSHShell.Run("calc.exe")
Upvotes: 11