To run an application using VB script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skbraja
    New Member
    • Nov 2006
    • 1

    #1

    To run an application using VB script

    Hi there
    I want to run an application (say BegUI). I tried to open the script conf.vbs as below
    Set objShell = WScript.CreateO bject("WScript. Shell")
    ObjShell.run("B egUI.exe") Or ObjShell.run("F ullPath")
    Set ObjShell=Nothin g
    But it says that file not found in line 2.

    I confirmed that is the right path. I tried to run it from Start->Run->Full Path of BegUI.exe. It has been executed well. When I double click the application file, it works fine.
    The problem here is it is not executed when I run using above script.

    Note: BegUI is an windows application. This application is an User Interface Application.Whe n you double click the exe, It displays just small menu window as you see when u right click any file. So My guess is I'm not recognizing the correct format or file.

    Can anybody help me runinng the above script giving me some suggestions?

    Thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    I'm not personally familiar with VBscript. Can someone tell me - does it run in a "sandbox"? Only, I wonder whether it is restricted in some way from running the program.

    Comment

    • diSangro
      New Member
      • Jan 2007
      • 69

      #3
      Try something like :
      ---------------------------------------------
      Dim p_ID

      Dim FullPath As String

      FullPath="C:\<p rog_path>\BegUI .exe"

      p_ID = Shell(FullPath, 1)

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

      now you can manage BegUI.exe using p_ID (task identifier), like this:

      AppActivate p_ID
      Application.Sen dKeys "%{F4}", True ' close BegUI.exe

      I think what you tried didn't work 'cause BegUI.exe is not the Win cmd shell ,
      use .Run to execute shell commands .


      Originally posted by skbraja
      Hi there
      I want to run an application (say BegUI). I tried to open the script conf.vbs as below
      Set objShell = WScript.CreateO bject("WScript. Shell")
      ObjShell.run("B egUI.exe") Or ObjShell.run("F ullPath")
      Set ObjShell=Nothin g
      But it says that file not found in line 2.

      I confirmed that is the right path. I tried to run it from Start->Run->Full Path of BegUI.exe. It has been executed well. When I double click the application file, it works fine.
      The problem here is it is not executed when I run using above script.

      Note: BegUI is an windows application. This application is an User Interface Application.Whe n you double click the exe, It displays just small menu window as you see when u right click any file. So My guess is I'm not recognizing the correct format or file.

      Can anybody help me runinng the above script giving me some suggestions?

      Thanks

      Comment

      • windson
        New Member
        • Aug 2007
        • 1

        #4
        Instead of ObjShell.run("B egUI.exe")
        try
        ObjShell.exec(" BegUI.exe")

        Shell.Exec command provides additional capability beyond the Shell.Run method. These abilities include:
        * Improved environment variable passing
        * Ability to access the standard streams of the executable

        Comment

        • egadgetguy
          New Member
          • Oct 2007
          • 1

          #5
          Originally posted by windson
          Instead of ObjShell.run("B egUI.exe")
          try
          ObjShell.exec(" BegUI.exe")

          Shell.Exec command provides additional capability beyond the Shell.Run method. These abilities include:
          * Improved environment variable passing
          * Ability to access the standard streams of the executable
          I searched high and low to find out how to run Flash Media Encoder from my script.
          This solution worked great. Thanks windson!!!

          Comment

          • Rettla
            New Member
            • Jan 2012
            • 28

            #6
            Thanks guys, I have been looking all over for this. I used a script with the code below to start winrar.

            Set objShell = WScript.CreateO bject("WScript. Shell")
            ObjShell.exec(" F:\Program Files\WinRAR\Wi nrar.exe")
            Set ObjShell=Nothin g

            Is it possible to add parameters such as the target and source folders for an unzip operation such that I can automate Winrar using the script?

            Comment

            • Guido Geurs
              Recognized Expert Contributor
              • Oct 2009
              • 767

              #7
              You must open a shell and follow the rules for the commandline of the program.
              for Winzip it's= program command ZIPfile Folder
              (command for extract => -e)

              Code:
              'Calling unzip function
              Set WshShell = WScript.CreateObject("WScript.Shell")
              WshShell.Run  """C:\Program Files\WinZip\WZUNZIP.EXE""" & " -e " & """E:\xfer4\DDAP.SPRD.JCH.E.zip""" & " " & """E:\xfer4"""
              This will extract all the files from E:\xfer4\DDAP.S PRD.JCH.E.zip to E:\xfer4

              Comment

              • Rettla
                New Member
                • Jan 2012
                • 28

                #8
                Originally posted by Guido Geurs
                You must open a shell and follow the rules for the commandline of the program.
                for Winzip it's= program command ZIPfile Folder
                (command for extract => -e)

                Code:
                'Calling unzip function
                Set WshShell = WScript.CreateObject("WScript.Shell")
                WshShell.Run  """C:\Program Files\WinZip\WZUNZIP.EXE""" & " -e " & """E:\xfer4\DDAP.SPRD.JCH.E.zip""" & " " & """E:\xfer4"""
                This will extract all the files from E:\xfer4\DDAP.S PRD.JCH.E.zip to E:\xfer4
                Tghank you so much Guido. It worked. I really appreciate it

                Comment

                Working...