启动其path包含空格的程序

我需要使用VBScript在本地系统中启动程序。 但是我在语法上遇到了麻烦。 这就是我现在使用的 –

Dim objShell Set objShell = WScript.CreateObject( "WScript.Shell" ) objShell.Run("iexplore") Set objShell = Nothing 

上面的代码成功启动IE。 我想启动其他浏览器。 但是,如果我使用 –

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

它抛出一个错误,说没有find文件或path。 我不知道如何运行()函数内的参数 – 我应该给的EXE的path,或者我应该给一些DOS命令?!

尝试:-

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

注意string中额外的“”。 由于exe的path包含空格,因此需要用引号将其包含在内。 (在这种情况下,简单地使用“firefox.exe”将工作)。

另外请记住,64位版本的Windows上的c:\ Program Files(x86)文件夹中存在许多程序。

正在合作

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

但是,如果我们只想input应用程序名称,应该是什么参数

例如在Internet Explorer的情况下

 WSHELL.Run("iexplore") 

你使用Exec

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

find你想要运行例子iexplore.exe和firefox.exe的应用程序的.exe文件,并删除.exe并在objShell.Run(“firefox”)中使用它

我希望这有帮助。

 Set objShell = WScript.CreateObject("WScript.Shell") objShell.Run("firefox") Set objShell = Nothing 

请试试这个

 set shell=CreateObject("Shell.Application") ' shell.ShellExecute "application", "arguments", "path", "verb", window shell.ShellExecute "slipery.bat",,"C:\Users\anthony\Desktop\dvx", "runas", 1 set shell=nothing 

你想要达到的目的很简单,而你所要做的却不是这样。 试试这个(对我来说工作正常),并从文本编辑器中保存为batch file。 相信我,这很容易。

 start firefox.exe 

复制文件夹,firefox.exe进入并放置在c:\中。 该脚本正在爬你的文件树很难。 我发现当我将* .exe文件放在c:\中时,它消除了“找不到文件”的错误消息。