Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyncToyQM
#1
I really like using SyncToy because it is really simple. http://www.microsoft.com/download/en/de ... 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
Code:
Copy      Help
function ~cl
#if EXE
cl=_command
#endif

if !(cl.len)
,ret
cl.lcase
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)
,return+1
iff-(Primary);;Test if primary directory exist, fails if not
,return+2
if !(Backup.len)
,return+4
iff-(Backup);;Tests if backup directory exists and creates
,if return=0
,,mkdir Backup
if !(Action="synchronize" or Action="echo" or Action="contribute")
,Action="echo"
;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"
_s="%ProgramW6432%"
iff(F"{_s.expandpath}\synctoy 2.1\synctoy.exe")
,EXEPath="%ProgramW6432%\synctoy 2.1\synctoy.exe"
,EXEPath1="%ProgramW6432%\synctoy 2.1\synctoycmd.exe"
EXEPath.expandpath
EXEPath1.expandpath
if return=0
,RunConsole2(F"''{EXEPath}'' -d(left=''{Primary}'',right=''{Backup}'',name=''{Name}'',operation={Action})" _s)
,Log.addline(_s)
,RunConsole2(F"''{EXEPath1}'' -r ''{Name}''" _s)
,Log.addline(_s)

Function ParseCommandLine
Code:
Copy      Help
;/
function $cmdLine ARRAY(str)&a

;Parses command line.
;Uses the same rules as most programs. <link "http://www.google.com/search?q=site%3amicrosoft.com%20Parsing%20C%2b%2b%20Command-Line%20Arguments">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.


a=0
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: 749)


Forum Jump:


Users browsing this thread: 2 Guest(s)