Launch programs whose path contains spaces

后端 未结 8 1138
余生分开走
余生分开走 2020-11-28 08:32

I need to launch programs in my local system using VBScript. But I am having trouble with the syntax. This is what I am using right now -

Dim objShell
Set o         


        
相关标签:
8条回答
  • 2020-11-28 08:34

    Try:-

    Dim objShell
    Set objShell = WScript.CreateObject( "WScript.Shell" )
    objShell.Run("""c:\Program Files\Mozilla Firefox\firefox.exe""")
    Set objShell = Nothing
    

    Note the extra ""s in the string. Since the path to the exe contains spaces it needs to be contained with in quotes. (In this case simply using "firefox.exe" would work).

    Also bear in mind that many programs exist in the c:\Program Files (x86) folder on 64 bit versions of Windows.

    0 讨论(0)
  • 2020-11-28 08:37

    What you're trying to achieve is simple, and the way you're going about it isn't. Try this (Works fine for me) and save the file as a batch from your text editor. Trust me, it's easier.

    start firefox.exe
    
    0 讨论(0)
  • 2020-11-28 08:39
    Set objShell = WScript.CreateObject("WScript.Shell")
    objShell.Run("firefox")
    Set objShell = Nothing
    

    Please try this

    0 讨论(0)
  • 2020-11-28 08:44

    It's working with

    Set WSHELL = CreateObject("Wscript.Shell")
    WSHELL.Exec("Application_Path")
    

    But what should be the parameter in case we want to enter the application name only

    e.g in case of Internet Explorer

    WSHELL.Run("iexplore")
    
    0 讨论(0)
  • 2020-11-28 08:46

    find an .exe file for the application you want to run example iexplore.exe and firefox.exe and remove .exe and use it in objShell.Run("firefox")

    I hope this helps.

    0 讨论(0)
  • 2020-11-28 08:47

    You van use Exec

    Dim objShell
    Set objShell = WScript.CreateObject( "WScript.Shell" )
    objShell.Exec("c:\Program Files\Mozilla Firefox\firefox.exe")
    Set objShell = Nothing
    
    0 讨论(0)
提交回复
热议问题