Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows vbscript找不到存储在google drive中的批处理文件_Windows_Batch File_Vbscript - Fatal编程技术网

Windows vbscript找不到存储在google drive中的批处理文件

Windows vbscript找不到存储在google drive中的批处理文件,windows,batch-file,vbscript,Windows,Batch File,Vbscript,我正在尝试在Windows 7上运行以下C:\users\jdoe\google drive\bin\script.vbs脚本: CreateObject("Wscript.Shell").Run "C:\users\jdoe\google drive\bin\run.bat", 0, True 但我总是犯错误: --------------------------- Windows Script Host --------------------------- Script: C:\User

我正在尝试在Windows 7上运行以下C:\users\jdoe\google drive\bin\script.vbs脚本:

CreateObject("Wscript.Shell").Run "C:\users\jdoe\google drive\bin\run.bat", 0, True
但我总是犯错误:

---------------------------
Windows Script Host
---------------------------
Script: C:\Users\jdoe\Google Drive\bin\script.vbs
Line:1
Char:   1
Error:  The system cannot find the file specified. 
Code:   80070002
Source:     (null)

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

OK   
---------------------------
当我将run.bat文件的路径更改为c:\run.bat并将run.bat文件移动到c:\,script.vbs运行时不会出现问题

有没有办法让我的脚本存储在google drive中运行?当使用本地组策略编辑器选择存储在google drive中的关机或登录/注销脚本时,我也遇到了同样的问题

非常感谢

CreateObject("Wscript.Shell").Run "C:\users\jdoe\google drive\bin\run.bat", 0, True
                                   ^..................^ ^...............^
                                   command to run        arguments  
您需要引用该命令以避免空格问题

CreateObject("Wscript.Shell").Run """C:\users\jdoe\google drive\bin\run.bat""", 0, True
请记住,字符串中的双引号需要转义,即在必须包含一个双引号的地方写入两个双引号

您需要引用该命令以避免空格问题

CreateObject("Wscript.Shell").Run """C:\users\jdoe\google drive\bin\run.bat""", 0, True

请记住,字符串中的双引号需要转义,在其中必须包含一个双引号的地方写入两个双引号。

为避免空格出现问题:您必须以这种方式尝试消除来自应用程序路径中空格的错误:

Option Explicit
Dim Application
Application = "C:\users\jdoe\google drive\bin\run.bat"
Call RunThis(Application)
'*********************************************************************************
Sub RunThis(Application)
    Dim Ws,Result
    Set Ws = CreateObject("WScript.Shell")
    Result = Ws.Run(DblQuote(Application),0,True)
End Sub
'*********************************************************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'*********************************************************************************

要避免空格出现问题:您必须以这种方式尝试消除来自应用程序路径中空格的错误:

Option Explicit
Dim Application
Application = "C:\users\jdoe\google drive\bin\run.bat"
Call RunThis(Application)
'*********************************************************************************
Sub RunThis(Application)
    Dim Ws,Result
    Set Ws = CreateObject("WScript.Shell")
    Result = Ws.Run(DblQuote(Application),0,True)
End Sub
'*********************************************************************************
Function DblQuote(Str)
    DblQuote = Chr(34) & Str & Chr(34)
End Function
'*********************************************************************************

您是否尝试以管理员身份运行脚本?Windows根据UAC权限使用wscript执行一些奇怪的重定向操作。您是否尝试以管理员身份运行该脚本?Windows根据UAC权限使用wscript执行一些奇怪的重定向操作。