Shell.Run Ws.CurrentDirectory +" \ somePath \ chrome.exe --app = https://a.com"现在工作

时间:2018-06-04 06:26:14

标签: vbscript

我想要一个用于打开Chrome并加载特定网址的vbs,但当目录包含空格时它不起作用。

我的代码How to call Run() with parameters,不起作用。我刚刚收到错误窗口

  

系统无法找到特定文件。错误代码:80070002

exchange.getOut().setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
exchange.getOut().setHeader("Pragma", "no-cache");
exchange.getOut().setHeader("Expires", "Mon, 01 Jan 1990 00:00:00 GMT");

我该如何解决这个问题?

更新1:

文件夹的结构:

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         2018/6/4     10:42                Chrome
-a----         2018/6/4     15:23            190 fso.vbs

Chrome的结构:

Chrome
 └─Application
    ├─61.0.3163.100
    │  ├─default_apps
    │  ├─Extensions
    │  ├─Installer
    │  ├─Locales
    │  ├─swiftshader
    │  ├─VisualElements
    │  └─WidevineCdm
    ├─Dictionaries
    ├─plugins
    ├─SetupMetrics
    └─chrome.exe

更新2:

我尝试了代码the error,将我的代码更改为:

Set Ws = CreateObject("WScript.Shell")
chromeLuncher = Ws.CurrentDirectory + "\Chrome\Application\chrome.exe --app=https://www.google.com --start-maximized"
Ws.Run DblQuote(chromeLuncher), 1, True

'****************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'****************************************

但仍然遇到同样的错误:

{{3}}

1 个答案:

答案 0 :(得分:0)

试试这段代码:

{{1}}

您可能已经调试了代码,并且您会看到为chrome指定的路径是错误的,这就是您在第3行收到错误的原因。

ShellExecute方法的文档:

https://msdn.microsoft.com/en-us/library/windows/desktop/gg537745(v=vs.85).aspx

编辑:您可以将chrome.exe安装文件夹的快捷方式放在vbs脚本的当前文件夹中。