Answered by:
Command Line option for -silent

Question
-
I am sync'ing as a scheduled task on a very regular basis (every 15 minutes).
My scheduled task command is this:
"C:\Program Files\SyncToy 2.0 Beta\SyncToyCmd.exe" -R
However, whenever this is run I get a Command Prompt Window briefly appearing as it is run. Does anyone know of a way of running the scheduled task so that this window does not appear. I was thinking of something like a -silent option on the command line executable - but that does not exist.
Perhaps I neet to wrap the sychtoycmd in something to make it silent?
Any help appreciated.
Thanks
LiamThursday, February 21, 2008 1:10 PM
Answers
-
I found this article and it works a treat: http://www.pcreview.co.uk/forums/thread-2125918.php
Set the scheduled task to run your command line from a batch file but using wscript as follows:
As an example, using notepad create .bat file called <SyncToy.bat> (without the <>) with the following line in:
"D:\Program Files\SyncToy 2.0 Beta\SyncToyCmd.exe" -R
Save SyncToy.bat in:
C:\Documents and Settings\Liam\My Documents\Schedule task synctoy
Now copy and paste the following lines to a new notepad and save as <BatchLauncher.vbs> in same directory as SyncToy.bat above:
'--------------------8<----------------------
sTitle = "Batch launcher"Set oArgs = WScript.Arguments
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")If oArgs.Count <> 1 Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: You need to supply a file path " _
& "as input parameter!", 10, sTitle, vbCritical + vbSystemModalWscript.Quit 1
End IfsFilePath = oArgs(0)
If Not oFSO.FileExists(sFilePath) Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: Batch file not found", _
10, sTitle, vbCritical + vbSystemModalWscript.Quit 1
End If' add quotes around the path in case of spaces
iRC = oShell.Run("""" & sFilePath & """", 0, True)' Return with the same errorlevel as the batch file had
Wscript.Quit iRC'--------------------8<----------------------
Note: It is the 0 in this line that hides the batch file execution:
iRC = oShell.Run("""" & sFilePath & """", 0, True)
If you want to run it visible, but minimized, change the 0 to 7.
Finally, create a scheduled task (or edit your current scheduled task) to run the following command:
wscript "C:\Documents and Settings\Liam\My Documents\Schedule task synctoy\BatchLauncher.vbs" "C:\Documents and Settings\Liam\My Documents\Schedule task synctoy\SyncToy.bat"
Obviously, from the above example you can use any file name and/or directory or expand on the command for synctoy in the .bat file to run any folder pairs to suit but should give you what you want without further explanations...
Jim
Saturday, February 23, 2008 8:52 AM
All replies
-
Hi Liam (great name by the way). :-)
Although we certainly get a LOT of requests for scheduled / background capabilities, we do not have a great solution for this right now.
Here is a link to a discussion on this topic.
Liam
Thursday, February 21, 2008 5:46 PM -
I found this article and it works a treat: http://www.pcreview.co.uk/forums/thread-2125918.php
Set the scheduled task to run your command line from a batch file but using wscript as follows:
As an example, using notepad create .bat file called <SyncToy.bat> (without the <>) with the following line in:
"D:\Program Files\SyncToy 2.0 Beta\SyncToyCmd.exe" -R
Save SyncToy.bat in:
C:\Documents and Settings\Liam\My Documents\Schedule task synctoy
Now copy and paste the following lines to a new notepad and save as <BatchLauncher.vbs> in same directory as SyncToy.bat above:
'--------------------8<----------------------
sTitle = "Batch launcher"Set oArgs = WScript.Arguments
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")If oArgs.Count <> 1 Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: You need to supply a file path " _
& "as input parameter!", 10, sTitle, vbCritical + vbSystemModalWscript.Quit 1
End IfsFilePath = oArgs(0)
If Not oFSO.FileExists(sFilePath) Then
' Will die after 10 seconds if no one is pressing the OK button
oShell.Popup "Error: Batch file not found", _
10, sTitle, vbCritical + vbSystemModalWscript.Quit 1
End If' add quotes around the path in case of spaces
iRC = oShell.Run("""" & sFilePath & """", 0, True)' Return with the same errorlevel as the batch file had
Wscript.Quit iRC'--------------------8<----------------------
Note: It is the 0 in this line that hides the batch file execution:
iRC = oShell.Run("""" & sFilePath & """", 0, True)
If you want to run it visible, but minimized, change the 0 to 7.
Finally, create a scheduled task (or edit your current scheduled task) to run the following command:
wscript "C:\Documents and Settings\Liam\My Documents\Schedule task synctoy\BatchLauncher.vbs" "C:\Documents and Settings\Liam\My Documents\Schedule task synctoy\SyncToy.bat"
Obviously, from the above example you can use any file name and/or directory or expand on the command for synctoy in the .bat file to run any folder pairs to suit but should give you what you want without further explanations...
Jim
Saturday, February 23, 2008 8:52 AM -
That is great, thanks Jim!
Liam
Saturday, February 23, 2008 4:01 PM -
Jim,
Perfect! I have now been using this for a week and I have no issues
Many Thanks
LiamDMonday, March 3, 2008 2:42 PM -
Hi Jim,
Thanks for your post. I have a quick question. I am not a scripter but realise that I need to enter variables within the script at:
iRC = oShell.Run("""" & sFilePath & """", 0, True)
Would you please give me a typical example of what the syntax needs to be on this line.
Many thanks
Justin
Wednesday, March 5, 2008 1:36 PM -
Justin, if you follow the above post there is no reason to enter any variables, the file name and path will be passed in the task scheduler's command line. The only work you need to do is create a directory and save the two files (.bat and .vbs) to that directory, if you use a different directory than in the example (highly likely) amend the task scheduler command line to the directory you locate the .bat and .vbs in.
Like you, I am not a scriptor but am pretty good at google, cut & paste
Kind regards, Jim.
Thursday, March 6, 2008 7:23 PM -
This was very helpful, I've now rolled it out over my users with the following mod -
The vbs file and SyncToy.bat are saved in C:\Program Files\SyncToy 2.0 Beta\ and the "Start in:" parameter of the scheduled task is set to that folder. The batch file includes a mod as follows:
SyncToyCmd -R > \\fileserver\SyncToyLogs\{username}.log
This redirect enables me to have the log files centralized in one location on a fileserver where we scan them using a script to match on any errors so that we can tell when daily backups of laptops to the fileserver have failed. Simple backup log monitoring of users daily data backups. Works really well.Tuesday, March 18, 2008 8:14 PM -
Nice 1 P4smort.
I use Synctoy to also backup all directories in 'My Documents' user directory, so generally anything I want to backup (or sync) I'll put in a dierctory under My Documents so it will automatically get backed up.
Currently I have six .bat files for six different synctoy scheduled taks I run so I also copy over the six .job (scheduled task file) to the 'Schedule task synctoy' directory in My Documents with all the .bat and .vbs scripts, so I know if anything goes bad (or re-build or re-install or upgrade Synctoy etc.) I should be in good shape to recover all these 'user' files and quickly set it all back and running quickly... hint.
Kind regards
Thursday, March 20, 2008 7:03 PM -
Hey guys,
I gave this a try thinking it would solve my problem of synctoy actually being visible as this is taking place, but it didn't. Does anyone have an idea as to how to get that to happen? The window briefly pops up for a minute while the sync takes place...Tuesday, May 27, 2008 8:22 PM -
Liam,
Yeah, but I have two folder pairs set up and I'd like to set them up to automatically sync every 7 days or whatever. As far as command prompt being silent (not popping up with the DOS-like box) Liam, I think you're looking to add the null command. You add that at the end of the batch file with a space in front of it and you're good to go. I use the null command with the >> command (note two >>'s!!!) to redirect the output from my simple batch file to a file, not the screen or to print; etc.
Here's my simple batch file that I copy and paste in certain directories that creates a (text) file listing of all the files in that particular folder (directory, I'm kinda old school...) and all subfolders, even system files and the like. With the current security settings in most PCs, you might have to adjust, but here it is if you want to play with it.
dir *.*/s >>file.txt null
I myself named it Z-Listing.bat so it will be at the bottom of the file listing when I sort the particular folder. It's great for looking for things, or just browsing when you don't really need to search, but just want to browse, say just going thru MP3s when you realize it's been awhile since you heard "It's a Wonderful World" by Louis Armstrong, for instance.
Take care,
Ted
Tuesday, June 10, 2008 12:39 AM -
Jim,
My only confusion lies in the fact that I have two folder pairs that I run in Sync Toy and I don't know how to specify them in Scheduled Tasks. I know there has to be an easy way to do this (or maybe it's not possible, which if so, that's just the way it is and tho it'd suck, I'd accept it).
Prob just something to annoy me, due to me being too lazy to do this about every seven days or so.... Heck, it's just my home PC and I'm medically retired, so it's no big deal. I play around doing betas and surfing the web, so I guess I'm just stumped.
Anyway, take care!
Ted
Tuesday, June 10, 2008 12:46 AM -
Thanks for posting this link Liam!!!!!!
Ted
BTW: That's why we're on here talking abt this (probs scheduling sync jobs)
Tuesday, June 10, 2008 12:49 AM -
Jim,
I think this would be way too overboard for most people. Heck, I'm thinking of expletives just looking at it! hahaha!! I say this because I'm not into scripts either. Actually not much into the command prompt either, but that's just me.
Thanks for your great posts,
Ted
Tuesday, June 10, 2008 2:58 AM -
Yeah I also use SyncToy to echo my My Documents folder (and all under it) from my Primary HDD (C:\) to a separate, Secondary HDD (D:\) as well as the whole Documents and Settings folders (mine, All Users, etc). It's quite nice for this and I do it abt every week or so. Going thru this newsgroup, now I have what I need (I believe!!!) to finally be able to schedule it (which I've already tried to do) and have it work (main thing!!!!) on a recurring basis. A home PC that I use and also use for beta testing, so it's not mission essential, but it's nice to have this and to have it work!
Ted
Tuesday, June 10, 2008 3:06 AM -
Why not skip the batch file with this vb script:
'--------------------------------------------------
Set oShell = CreateObject("WScript.Shell")sFilePath = chr(34) & "C:\Program Files\SyncToy 2.0\SyncToyCmd.exe" & chr(34) & "-R"
iRC = oShell.Run(sFilePath, 0, True)
' Return with the same errorlevel as the batch file had
Wscript.Quit iRC
'---------------------------------------------------Monday, March 23, 2009 5:35 PM -
This is really a smart idea, Jim. :)
HI Norlando,
I assume that Jim using a batch file because of it's easy to custom paramater of SyncToyCmd.exe, when you want to sync one or more speficiy sync folder pairs.
Joey Liang
Your potential our passion This posting is provided "AS IS" with no warranties, and confers no rights.Thursday, March 26, 2009 4:15 PM -
just run the schedule under a different users credentials. just make sure that user has permission to access the folders you want. i created a user called synctoy and gave it a password.
no more poppy uppy every 5 minutesMonday, May 4, 2009 8:01 PM -
I like wirerogue's answer. :) It worked for me.Tuesday, April 19, 2011 7:56 PM
-
Hi P4smort,
Can you help me out on pointing the logs to... SyncToyCmd -R > \\fileserver\SyncToyLogs\{username}.log
as you have mentioned you were able to get log reports incase of failures or what not....can you tell me how did you set it up to create such logs.....logs are very essentials..
and you were able to get on the reports...good for you man!!
please help!!
Thursday, July 7, 2011 9:13 AM -
Thank you Norlando,
this definitely works.......so cool, now I am only monitoring its consistency in running the scheduled task!!
sorry to post late....It happens that I now use SyncToy !!
regards to all of you ........ who were able to contribute to this forum!!!
Thursday, July 7, 2011 9:19 AM -
Very nice. Now, if we can just get SyncToy running across all users on a machines in the background, we're in business! Thanks for all of it.Thursday, July 28, 2011 12:46 PM
-
To avoid the taskeng.exe window from popping up ever time the scheduler runs SyncToyCmd, I use a script. I created the following script in notepad and then saved is as SyncToy.vbs and then get Task Scheduler to run that instead:
‘ SyncToy Scheduler Set WshShell = WScript.CreateObject(“WScript.Shell”) WshShell.Run “”"C:Program FilesSyncToy 2.1SyncToyCmd.exe”" -R” ,7
The ‘,7′ will start the taskeng.exe window minimised, to hide the window completely it can be changed to ‘,0′Tuesday, September 6, 2011 6:13 PM -
Thanks to everyone on this thread.
Quick update for anyone who might be confused - the script above needs to be changed to 2.1 as SyncToy has been updated :)
-------
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
Friday, September 14, 2012 3:27 PM -
I hate the window showing on top but a batch file seems like overkill to me so I did this.
The action for the Scheduled Job is configured like this:
In Edit Action dialog window:
Program/script: C:\Windows\System32\cmd.exe
Arguments: /c start "Scheduled Task - SyncToy" /MIN "C:\Program Files\SyncToy 2.1\SyncToyCmd.exe" -R
It flashes a window very quickly then launches a new window with the SyncToy running but it's minimized. That way I'm not interrupted every hour when my job runs.
Tuesday, January 5, 2016 1:52 PM