Error Using .RUN to Start a Program Minimized

Answered Error Using .RUN to Start a Program Minimized

  • Thursday, May 17, 2012 6:30 PM
     
     

    I am trying to write a small script to launch 3 programs, with 2 of them minimized.

    The following script works:

    ----------------

    Dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Exec("C:\Program Files (x86)\K7JNX\DM780-DXL\DM780-DXL.exe")
    WScript.Sleep(1000)
    WshShell.Exec("C:\Program Files (x86)\Amateur Radio\Ham Radio Deluxe\HRDLogbook.exe")
    WScript.Sleep(1000)
    WshShell.Exec("C:\Program Files (x86)\Amateur Radio\Ham Radio Deluxe\Digital Master.exe")

    ----------------

    However, if I try the same thing with the Run command:

    ----------------

    Dim WshShell
    Set WshShell = WScript.CreateObject("WScript.Shell"
    WshShell.Run "C:\Program Files (x86)\K7JNX\DM780-DXL\DM780-DXL.exe", 7
    WScript.Sleep(1000)
    WshShell.Run "C:\Program Files (x86)\Amateur Radio\Ham Radio Deluxe\HRDLogbook.exe", 7
    WScript.Sleep(1000)
    WshShell.Exec("C:\Program Files (x86)\Amateur Radio\Ham Radio Deluxe\Digital Master.exe")

    ----------------

    I get a "The system cannot find the file specified" error at Line 3, Char 1.

    I have done this same thing in other scripts with no problems.

    System OS is Win7 (64-bit).

    What is going on?


    Ray Andrews

All Replies

  • Thursday, May 17, 2012 6:39 PM
    Moderator
     
     
    Set WshShell = WScript.CreateObject("WScript.Shell"

    You are missing the closing ) character on that line.

    Bill

  • Thursday, May 17, 2012 6:48 PM
     
     

    Bill,

    That is merely a typo in the post.  The closing ")" is there in the real file.  Besides, that is line 2.  The error is occurring on line 3, the line beginning "WshShell.Run".

    Ray


    Ray Andrews

  • Thursday, May 17, 2012 7:23 PM
    Moderator
     
     Answered Has Code

    Hi,

    One thing at a time. IIRC, the Run method needs quotes if the command contains spaces; e.g.:

    WshShell.Run """C:\Program Files (x86)\K7JNX\DM780-DXL\DM780-DXL.exe""", 7

    HTH,

    Bill

    • Marked As Answer by RNAndrews45 Thursday, May 17, 2012 7:27 PM
    •