6

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?

Boris Raznikov
  • 2,373
  • 10
  • 34
  • 56

4 Answers4

11

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")

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Good answer, but I just want to note that `WSHShell` needs to be initialised first. Here's an example using Internet Explorer: `CreateObject("WScript.Shell").Run("iexplore")` – Dog Lover Aug 11 '15 at 08:49
4
  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.

2

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.

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
1
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.

Nick
  • 138,499
  • 22
  • 57
  • 95