VB Script to Silently Synchronize ftp site to local dir.
I wrote this script to be called by task scheduler to synchronize a FTP site to a local directory, with a size criteria and to delete any changes to local directory. Also, This script will first check to see if Winscp.exe is running, and close it and restart the sync if the scheduled task runs into the next time it runs.It also calls a batch file that uses the /script switch with the .exe to run silently.
Here is the vbs script.
Here is the bat file
If you guys see anything i can do differently please let me know.
Here is the vbs script.
strComputer = "." strProcessToKill = "winscp.exe" SET objWMIService = GETOBJECT("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") SET colProcess = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = '" & strProcessToKill & "'") sub shell(cmd) ' Run a command as if you were running from the command line dim objShell Set objShell = WScript.CreateObject( "WScript.Shell" ) objShell.Run(cmd) Set objShell = Nothing end sub count = 0 FOR EACH objProcess in colProcess objProcess.Terminate() count = count + 1 Next shell "C:\admin\sync.bat"
Here is the bat file
@echo off cd C:\program files\winscp\ start /b winscp.exe /script=sync1.txt exit
If you guys see anything i can do differently please let me know.