Vbscript VBS同步中心同步脱机文件

Vbscript VBS同步中心同步脱机文件,vbscript,center,synchronisation,Vbscript,Center,Synchronisation,我正在尝试使用VBScript同步脱机文件。我已编辑以下代码以同步三个路径: Set wshShell = CreateObject( "WScript.Shell" ) strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" ) strPathProfile = "\\SRV01\Path1$\" & strUserName strPathHome = "\\SRV01\Path2$\" & strUserN

我正在尝试使用VBScript同步脱机文件。我已编辑以下代码以同步三个路径:

Set wshShell = CreateObject( "WScript.Shell" )
strUserName = wshShell.ExpandEnvironmentStrings( "%USERNAME%" )

strPathProfile = "\\SRV01\Path1$\" & strUserName
strPathHome = "\\SRV01\Path2$\" & strUserName
strPathShared = "\\SRV01\Path3$"

    SynchronizeOfflineFiles strPathProfile
    SynchronizeOfflineFiles strPathShared
    SynchronizeOfflineFiles strPathHome

Sub SynchronizeOfflineFiles(strSyncPath)
Dim objShell
Dim objFolderPath
    Set objShell = CreateObject("shell.application")
    Set objFolderPath = objShell.NameSpace(strSyncPath)

    If (not objFolderPath is nothing) then
        objFolderPath.Synchronize

    End If

    Set objFolderPath = nothing
    Set objShell = nothing
End Sub
我唯一的问题是同步中心将一个接一个地同步路径,结果其中两个路径将失败。顶部的路径(在本例中为strPathProfile)将成功。因此,如果我将顺序更改为,例如:

SynchronizeOfflineFiles strPathHome
SynchronizeOfflineFiles strPathShared
SynchronizeOfflineFiles strPathProfile
strPathHome将成功,其他两个将失败

当我像这样使用
WScript.Sleep 5000
命令时:

SynchronizeOfflineFiles strPathProfile
WScript.Sleep 30000
SynchronizeOfflineFiles strPathShared
WScript.Sleep 30000
SynchronizeOfflineFiles strPathHome
它将等待其他路径同步,但我必须设置时间。是否可以等到上一次同步完成


我还收到错误:当其中一个共享脱机时,没有文件扩展名“.vbs”的脚本引擎。我可以让脚本检查共享是否联机,如果不联机,请跳到下一个吗?

您的问题是,在第一个共享完成之前,您运行了子SynchronizeOfflineFiles。然后,当它这样做时,您将objFolderPath设置为nothing


您可以在前一个参数完成后使用不同的参数运行sub,也可以使用不同的ToBjFolderPath编写多个版本的SynchronizeOffline文件。

奇怪的是,如果我使用不同的ToBjFolderPath编写多个版本的SynchronizeOffline文件,它将不会同步我请求的唯一路径。但是如果我像以前一样把三条路径放在一起,它将同步一条路径。但其他两条路径的状态为:同步挂起。当第一条路径同步时,它们将失败。当我按下Sync Center中的Sync All按钮时,它将同时同步所有路径而不会出错。使用vbs脚本是否可以执行此操作?