Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I really like using SyncToy because it is really simple. ... x?id=15155

The problem is that if it is set up as a scheduled task, it uses a different command line exe. When calling this exe from the TaskScheduler a command prompt is present. I tried a whole bunch to get rid of this command prompt by trying to run in silent or what not...had no luck.

The other pitfall is the Sync has to be set up for the command line to run it.

I whipped up this little guy to manage SyncToy better for TaskScheduler (Uses Gintaras' ParseCommandLine function to run):
Function SyncToyQM
Copy      Help
function ~cl
#if EXE

if !(cl.len)
ARRAY(str) a
;Parses out Command Line data:
ParseCommandLine(cl a)
for int'i 0 a.len
,sel a[i]
,,case "/name"
,,str Name=a[i+1]
,,case "/primary"
,,str Primary= a[i+1]
,,case "/backup"
,,str Backup=a[i+1]
,,case "/action"
,,str Action=a[i+1]
int return
;Set default values or error:
if !(Name.len)
,Name.timeformat("Backup {yyyy}-{MM}-{dd} {HH}:{mm}:{ss}")
if !(Primary.len)
iff-(Primary);;Test if primary directory exist, fails if not
if !(Backup.len)
iff-(Backup);;Tests if backup directory exists and creates
,if return=0
,,mkdir Backup
if !(Action="synchronize" or Action="echo" or Action="contribute")
;Test for 32-bit or 64-bit version (Uses 64-bit version if both are present)
str EXEPath EXEPath1
iff("$program files$\synctoy 2.1\synctoy.exe")
,EXEPath="%programfiles%\synctoy 2.1\synctoy.exe"
,EXEPath1="%programfiles%\synctoy 2.1\synctoycmd.exe"
iff(F"{_s.expandpath}\synctoy 2.1\synctoy.exe")
,EXEPath="%ProgramW6432%\synctoy 2.1\synctoy.exe"
,EXEPath1="%ProgramW6432%\synctoy 2.1\synctoycmd.exe"
if return=0
,RunConsole2(F"''{EXEPath}'' -d(left=''{Primary}'',right=''{Backup}'',name=''{Name}'',operation={Action})" _s)
,RunConsole2(F"''{EXEPath1}'' -r ''{Name}''" _s)

Function ParseCommandLine
Copy      Help
function $cmdLine ARRAY(str)&a

;Parses command line.
;Uses the same rules as most programs. <link "">Read more</link>.

;cmdLine - command line.
;;;Can be path followed by command line. Then a[0] will be the path.
;a - receives command line arguments.

if(empty(cmdLine)) ret
int i n
word** w=CommandLineToArgvW(@cmdLine &n)
for(i 0 n) a[].ansi(w[i])

LocalFree w

Any suggestions to make this function better are definitely welcome.

Attached Files
.qml   SyncToyQM.qml (Size: 2.05 KB / Downloads: 424)

Forum Jump:

Users browsing this thread: 1 Guest(s)