Answered by:
Running an application on WHS from a client

Question
-
I have SyncToy installed on my WHS - I use it to echo my Music share to an external HD plugged into the server.
Can I run the SyncToy script from my desktop client so that it automates the process of opening a RDC and running the script (actually a batch file on the desktop of the server)?
Friday, June 4, 2010 8:49 PM
Answers
-
Finally got there!
I managed to get the backup to work automatically when I plug the external HD into the server.
I created a scheduled task on the server to run the following .bat file every minute:
if exist F:\Music goto backup
goto notexists:backup
if exist c:\backup.flg goto end
echo. > c:\backup.flg
"C:\Program Files\SyncToy 2.1\SyncToyCmd" -R "Music Backup"
goto end:notexists
if exist c:\backup.flg del c:\backup.flg- Marked as answer by spile1 Thursday, June 10, 2010 11:42 AM
Thursday, June 10, 2010 11:40 AM
All replies
-
You could set up a scheduled task on your server which would run synctoy for you. Probably you could use the batch file you have now, though you'll need to be careful of the context it's running in if you set it up as a scheduled task. You can even run scheduled tasks remotely, if permissions are set correctly, so you could run it "on demand" rather than on a set schedule. There are other options as well, for example you could set up your external HD to automatically run a script to copy your files when it's connected to your server.
None of this is "supported", of course. :) You can learn lots more about all this sort of thing from any halfway decent book on Windows administration; it's too complex a topic to go into here, I'm afraid. Or you can browse through Technet...
I'm not on the WHS team, I just post a lot. :)- Proposed as answer by kariya21Moderator Saturday, June 5, 2010 10:02 PM
Friday, June 4, 2010 10:46 PMModerator -
A scheduled task isn't appropriate in this context as I plug in the external drive at different times and days.
Well I've found out that I can access the WHS destop by using mstsc /v: servername
What I need is a way of appending the run command but this doesn't work:
mstsc /v: servername "C:\Program Files\SyncToy 2.1\SyncToyCmd" -R "Music Backup"
Saturday, June 5, 2010 11:30 AM -
What you say you want to do isn't really possible, unless you can find some tool that can automate a Remote Desktop session for you. I presented some alternatives which should work; why not look into them and see what you can come up with?
And a scheduled task can do the job for you as well; read up on advanced batch (and other) scripts, and the advanced uses of Task Scheduler.
I'm not on the WHS team, I just post a lot. :)Saturday, June 5, 2010 12:50 PMModerator -
Apologies I think I may have misinterpreted what I am after by using the phrase automated.
Basically this is what I'm after....
Plug my external USB drive into WHS.
From my destop, run a .bat file that initiates a backup
Thanks for your suggestions.
Sunday, June 6, 2010 9:28 AM -
You could set up a scheduled task on your server which would run synctoy for you.
I am investigating this option by using the facility to run the task "At log on" however this process of running a RDP connection doesn't cause the task to run which implies that initiating RDC doesn't actually constitute a log on???
Monday, June 7, 2010 7:37 PM -
There is a command line tool, schtasks, which can run a scheduled task on a remote computer. You'll find more information about it in the help files for your client operating system, on the Microsoft Support site, and on Technet. As well as all over the internet via your search engine of choice. :)
I'm not on the WHS team, I just post a lot. :)Tuesday, June 8, 2010 1:05 AMModerator -
It seems that using schtasks rather than the GUI offers no way round the problem of recognising that RDC constitutes a log in so that line of attack appears to be closed to me.
It has been suggested that I look at gpedit.msc to see if a login script will run if placed there.
Wednesday, June 9, 2010 7:51 AM -
Forget about Remote Desktop. You don't need to log in to your server every time you want your files copied.
You can trigger a scheduled task without logging in to the desktop; schtasks is one way (not the only way) to do so remotely. If you have a need for the task to run in a particular security context on the remote computer (your server), you just set it up with the correct credentials. When triggered, it runs, does whatever it's supposed to, and finishes. This isn't something an average home user will ever need to be able to do, but it's not rocket science, either.
I'm not on the WHS team, I just post a lot. :)Wednesday, June 9, 2010 10:07 AMModerator -
Finally got there!
I managed to get the backup to work automatically when I plug the external HD into the server.
I created a scheduled task on the server to run the following .bat file every minute:
if exist F:\Music goto backup
goto notexists:backup
if exist c:\backup.flg goto end
echo. > c:\backup.flg
"C:\Program Files\SyncToy 2.1\SyncToyCmd" -R "Music Backup"
goto end:notexists
if exist c:\backup.flg del c:\backup.flg- Marked as answer by spile1 Thursday, June 10, 2010 11:42 AM
Thursday, June 10, 2010 11:40 AM -
I kind of thought that a scheduled task would wind up being your fallback. :)
I'm not a fan of semaphore files. However, they're often the only reasonable way to get something to work. Personally I'd probably use a scripting language like VBScript rather than a batch file, but I bet I'd still wind up using a semaphore.
I'm not on the WHS team, I just post a lot. :)Thursday, June 10, 2010 12:38 PMModerator -
Personally I'd probably use a scripting language like VBScript rather than a batch file,
For what reason?Friday, June 11, 2010 10:49 AM -
More power, more control, more flexibility, more opportunity for error handling. You can write a complex batch script with branching and error handling, but frankly it's painful compared to doing the same thing in VBScript. Even though the VBScript version would probably be much longer.
I'd say "I would do it in PowerShell" but this isn't a good candidate for PowerShell, except in the sense that "If all you have is a hammer, everything looks like a nail." :)
Bottom line, though, is to use the tool you're most comfortable with that does the job. If that's a batch script, there's nothing wrong with it.
I'm not on the WHS team, I just post a lot. :)Friday, June 11, 2010 12:17 PMModerator -
I think I'll avoid the sledghammer as my nut is adequately cracked :-)Friday, June 11, 2010 12:58 PM