Automating a process in Windows
January 31, 2005 10:38 AM   RSS feed for this thread Subscribe

I'd like to automate some sort of synchronize process to run every time I start/close a separate application in Windows. It should download a data file on launch and upload after exiting, without having to think about it. Is there any easy way to do this? Preferably using SFTP or another secure method.
posted by sfluke20 to computers & internet (13 comments total)
Do you mean you want to edit a file which is on an ftp site, and upload the modified file to the same site?

One option is to make the ftp site into a "network drive"; there are a couple of ways to do this under ms windows, samba being the best bet.

If that's not possible, WinSCP is a Windows SFTP client that'll allow you to click and edit files on the foreign server.

If that doesn't work, you can do explicitly what the above solutions really do: write a batch file to download the files, save it to a temporary location, start your editing application on the local copy, and upload the modified copy after your editing application closes.
posted by orthogonality at 11:17 AM on January 31, 2005


If I understand you correctly, I'd write a quick batch script that starts the transfer (using whatever means you like), and then starts your program. Use the batch script's shortcut instead of your program's.
posted by RikiTikiTavi at 11:21 AM on January 31, 2005


I think sfluke20 is looking for a solution to automate the following:

1) Download data from remote server
2) Use application to use (edit?) data
3) On application exit, upload modified data back on the website

For example, if the application was Firefox, and the data was bookmarks, I would say Bookmark Synchronizer (although mine stopped automated dl/ul for no reason, I now have to do it manually).

sfluke20, I think if you give us a little more specifics (what is the data and what application are you talking about), perhaps we could be more helpful...
posted by tuxster at 11:51 AM on January 31, 2005


Right tuxtster, exactly what you described.

I have an application that has a single binary data file. I'd like to be able to run the app in multiple places, using the same data file, without having to worry about manually synchronizing the data.

(Bonuses would be to somehow backup the data file somewhere in the process)
posted by sfluke20 at 11:58 AM on January 31, 2005


heh, meanwhile the page I linked to actually had the solution to the problem I'm having with Bookmark Synchronizer...
posted by tuxster at 11:59 AM on January 31, 2005


sfluke20, download pscp, which will let you upload/download a file to a remote server running ssh or sftp. Then make a .bat file with the contents:

pscp user@site.com:somefile.dat "C:\some directory\"
"C:\Program Files\Some App\app.exe"
pscp "C:\Some Direcotory\somefile.dat" user@site.com:


That should do it. The pscp process will ask you for a password each time. You could avoid the password process by using a public/private key in conjunction with puttygen/pageant, available on the PuTTY page I liked to above. It's kind of involved, so get the normal password way working first.
posted by zsazsa at 1:58 PM on January 31, 2005


Cool -- I just came back to say I'd gotten that exact same thing working. With the public/private key stuff. Exactly what I want -- although the little batch file window is a little annoying (I'll deal with it!). Thanks everyone!

Now just gotta figure out how to create a date variable in the batch file.
posted by sfluke20 at 2:16 PM on January 31, 2005


Be careful with batch files though. If your batch file says (for example)

notepad
word
notepad

It won't run one program, wait for it to finish and then run the other. It'll run all three programs at once. (not strictly true, but that's what it'll look like to you).

for Date, use command line variable %date%
e.g. echo %date%

To do this properly some kind of vbscript may be the answer.
posted by seanyboy at 3:37 PM on January 31, 2005


In Win2K, batch files do execute commands sequentially; a command doesn't execute until the previous command finishes and the command doesn't finish until any application it calls terminates. That may not be the case with other versions of windows though.

If you create a shortcut to the batch file you can specify in the properties of the batch file for it to run minimized (or maximized or normal, the default). The annoying command window will still be there, you just won't see it. Again, I'm talking about Win2K.
posted by TimeFactor at 5:25 PM on January 31, 2005


...the properties of the shortcut to the batch file...
posted by TimeFactor at 5:27 PM on January 31, 2005


Not always. Try putting this in a batch file, and see what happens.
"C:\Program Files\Mozilla Firefox\firefox.exe""C:\Program Files\Mozilla Firefox\firefox.exe""C:\Program Files\Mozilla Firefox\firefox.exe"explorerexplorer
You'll have to run app.exe, and see if it waits.
posted by seanyboy at 2:40 AM on February 1, 2005


seanyboy: yup, I get three instances of firefox and two of explorer. Your earlier example and others I've tried do behave as I described; I'm not sure why there's a difference but there is.
posted by TimeFactor at 10:01 AM on February 1, 2005


Huh. Runs sequentially for me in Windows XP ... Exactly what I want.
posted by sfluke20 at 10:06 AM on February 1, 2005


« Older Help us Find That Flick! It's ...   |   Is posting an ad on Monster.co... Newer »
This thread is closed to new comments.