Page 2 of 2

Re: Real-time sync of large files.

Posted: Tue May 24, 2011 1:59 pm
by RiseFly
Re i) If you use the command line with /nosvc option, even a task in the normal project file will run once, but please do not run the real-time task, it will never end.

Re ii) If you start the task by command line, and the task is already running, the task will be started twice. It will find the changed files and sync them. If the two same tasks run simultaneously, one file may be copied twice, or fail with access denied error.

If the task is not set as a real-time sync task, BestSyncSvc.exe will end after the task finishs. You can us the following script to detect whether BestSyncSvc.exe is running, if it is running, just wait for it ends.
------------------------------------------------------------------------------
set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='BestSyncSvc.exe'"
set cproc=svc.execquery(sQuery)
iniproc=cproc.count 'it can be more than 1
Do While iniproc = 1
wscript.sleep 2000
set svc=getobject("winmgmts:root\cimv2")
sQuery="select * from win32_process where name='BestSyncSvc.exe'"
set cproc=svc.execquery(sQuery)
iniproc=cproc.count
Loop
------------------------------------------------------------------------------

Re: Real-time sync of large files.

Posted: Tue May 24, 2011 11:36 pm
by gdu90
re. (i), this is working as you describe with "/NoSvc". The new service runs the specified task and then ends. Thanks.

However,

re. (ii) if there is already an instance of the service running, the script does not end. In taskmgr.exe you can see the new instance start, sync, and end (as per (i) above) but the old instance is still running so the query still returns a "hit" and the script keeps looping. It is afterwards possible to stop this old instance by command line with "/Stop" but you cannot script this to happen AFTER the new instance runs because the script will never get that far; it must be stopped BEFORE the new instance is launched. And it is necessary to wait after issuing this "/Stop" before launching the new instance, so that the correct instance is stopped.

So, my questions to script this -
(a) what is the behaviour of BestSyncSvc.exe when a stop is issued in the middle of a sync, does it stop immediately or does it complete the sync and then stop ?
(b) Is there any way to detect in a script whether a sync is actually in progress ?
(c) If there are TWO instances already running (eg. by two user logons), will one "/Stop" stop them both, or do you need to issue one "/Stop" per instance/user ?