2
votes

we have this vbs script we use to update certain documents with SyncToy.

This is the script as it is currently written:

'--------------------------------------------------

Set oShell = CreateObject("WScript.Shell")

sFilePath = chr(34) & "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" & 
chr(34) & "-R"

iRC = oShell.Run(sFilePath, 0, True)

' Return with the same errorlevel as the batch file had
Wscript.Quit iRC


'---------------------------------------------------

I didn't write this script, and I have very little experience with scripting.

I have a task set up in task scheduler that runs this script anytime the device connects to a network. The script should run SyncToy and then synchronize the folder pair that is set up. I have tried running the script through command prompt with the cscript command but nothing happens as far as I can tell. At least the folders aren't syncing.

The script is running on a Windows 10 pro tablet

I have verified that the task is indeed running when it is supposed to. I'm just not sure if it is an issue with the way the script is written or if the task settings need to be changed. Is there anything wrong with the script as far as you can tell?

I was unsure whether to post this here or over in serverfault. If this doesn't belong here please move the question over to serverfault

Update: I've verified that this isn't a problem with the script. This problem apparently arose only after the update from SyncToy 2.0 to 2.1.

Thanks Guys.

1
You need a space inside "-R" - it should look like " -R"- @Tommy shows the line correctly - if that's the way it is in your code please edit and update your question. Also -if you are doing this in a scheduled task, you need to specify the start in folder - it's a weird VBS issue with Windows Tasks.dbmitch

1 Answers

0
votes

There is a error with the sFilePath lines. First, I don't know if this was originaly on a single line but it should (or add "_" before changing line).

Then, this (...)& >"-R" would not work. The ">" symbole is outside the quotes and generate a error.

If you want to execute this command: "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" -R, this is the way to do this:

sFilePath = chr(34) & "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" & chr(34) &  " -R"

You can also add msgbox sFilePath to show a popup with the value of sFilePath. To test/run the script, you just need to double-click on it.