Boris Raznikov
Boris Raznikov

Reputation: 2453

vbscript start a process

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

Answers (4)

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

user6842283
user6842283

Reputation:

  1. 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 
    
  2. Starting a normal process

    code

       Dim shl  
       Set shl = CreateObject("Wscript.Shell")  
       Call shl.Run("""D:\testvbs\someServices.exe""")  
       Set shl = Nothing    
       WScript.Quit
    
  3. You can launch any batch file too using VBscript. just provide the path of batch file in shl.run() while calling it.

Upvotes: 4

Ekkehard.Horner
Ekkehard.Horner

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

SLaks
SLaks

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

Related Questions