Martin Zugec Posted March 21, 2005 Posted March 21, 2005 The main idea behind this script is to automatically download new versions of software (based on timestamp on server). It is quite easy and simple. 1.) Download necessary files You need wget and tfind. You can download them here:WGETTfind2.) Create Update.ini You need to create settings file. It consist of three sections:boolMail - If you want to be notified (or your coworkers) by email when new version is available, set this to on. You need to edit internal-Mail.vbs and set SMTP server address, From and To. boolProxy - available settings are on/off. This settings describes if you use proxy or not.http_proxy - address of your proxy server in case boolProxy is on. LogDirectory - Directory, where you want to store your log files.Example of update.ini:boolMail=onboolProxy=onhttp_proxy=http://proxy.domain.com:80LogDirectory=\\server\share\logs\update 3.) Create script files In this step you need to create script files internal-download.bat, update.bat and optional internal-mail.vbsupdate.bat:@echo offIf "%1" EQU "" Echo You must provide parameter with update group! && Goto :EOFSet UpdateGroup=%1Title %UpdateGroup% updatingSet MainDirectory=%cd%If not exist "%MainDirectory%\Update.ini" Echo Missing Update.ini file!!! && Pause && Goto :EOFFor /f "usebackq tokens=1,2 delims==" %%i IN (`type "%MainDirectory%\Update.ini"`) DO Set %%i=%%jIf not exist "%MainDirectory%\%UpdateGroup%" mkdir "%MainDirectory%\%UpdateGroup%" cd %UpdateGroup%Echo Removing log filesIf Exist "%LogDirectory%\%UpdateGroup%\Details" rmdir /q /s "%LogDirectory%\%UpdateGroup%\Details"Echo Removing error logIf Exist "%LogDirectory%\%UpdateGroup%\error.log" del /q "%LogDirectory%\%UpdateGroup%\error.log"Echo Creating log directorymkdir "%LogDirectory%\%UpdateGroup%\Details"Echo Creating temp file for case where nothing is updatedecho. > "%MainDirectory%\%UpdateGroup%\working.txt"FOR /F "tokens=1,2,3,4 delims=; " %%i in (..\%UpdateGroup%.ini) do call ..\internal-Download.bat %%i %%j %%kIf exist "%MainDirectory%\%UpdateGroup%\working.txt" echo %date:~3,11%;No newer versions available >> "%LogDirectory%\%UpdateGroup%\aktualizacie.log"pause internal-Download.bat:@echo offrem %1 = Product namerem %2 = Log file namerem %3 = URL addressEcho Downloading %1wget --timestamping --output-file="%2" --server-response --proxy=%boolProxy% %3call tfind.com /e "Saved" %2set update=%errorlevel%if %update% GTR 0 ( Echo %1 updated If exist "%MainDirectory%\%UpdateGroup%\working.txt" del /q "%MainDirectory%\%UpdateGroup%\working.txt" > nul echo %date:~3,11%;%1;Success>> "%LogDirectory%\%UpdateGroup%\aktualizacie.log" move /Y %2 "%LogDirectory%\%UpdateGroup%\Details" If /i %boolMail% EQU on cscript //nologo "%MainDirectory%\internal-mail.vbs" /update:%1 Goto :EOF )call tfind.com /e "no newer" %2set nonewer=%errorlevel%If /i %nonewer% GTR 0 ( move /y %2 "%LogDirectory%\%UpdateGroup%\Details" Goto :EOF )Echo %date:~3,11%;%1;Error! >> "%LogDirectory%\%UpdateGroup%\error.log"Echo %date:~3,11%;%1;Error! >> "%LogDirectory%\%UpdateGroup%\aktualizacie.log"move /y %2 "%LogDirectory%\%UpdateGroup%\Details"internal-Mail.vbs (this file is optional!)'Automatic mail notifications'Soulin (www.supersupport.org)'11.11.2004Option ExplicitOn Error Resume NextDim objArguments, objNamedset objArguments = WScript.Argumentsset objNamed = WScript.Arguments.NamedCall OdoslanieMailuSet objShell = NothingWscript.Quit(0)Sub OdoslanieMailu Dim objEmail, objNetwork Dim strComputerName Set objEmail = CreateObject("CDO.Message") Set objNetwork = CreateObject("Wscript.Network") strComputerName = objNetwork.ComputerName With objEmail .From = "autoupdate@supersupport.org" .To = "recipient1@supersupport.org,recipient2@supersupport.org" .Subject = "Software " & objNamed("update") & " was actualized." .Textbody = "New software version was detected and automatically downloaded. You can find it here:\\server\share\tools. If you dont want to receive this mails, send blank email to autoupdate@supersupport.org." .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.supersupport.org" .Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 .Configuration.Fields.Update .Send End With Set objEmail = Nothing Set objNetwork = NothingEnd Sub4.)Create .ini files Final step - you need to create different sets of .ini files. Every ini file represents the category to download, for example in spyware.ini you can find all different kinds of antispyware programs, in tools.ini you can find tools etc.Syntax of ini files is as follows:UserName;LogFile;URL linkFor example my Spyware.ini file:KillBits;killbit.log;http://www.spywareguide.com/blocklist.regRestrictedSites;restrict.log;https://netfiles.uiuc.edu/ehowes/www/res/ie-spyad.zipRestrictedSites2;rest2.log;https://netfiles.uiuc.edu/ehowes/www/res/ie-spyad2.zipSpybot;spybot.log;http://www.spybotupdates.com/updates/files/spybotsd_includes.exeSpywareBlaster;blaster.log;http://securityhelpers.net/downloads/spywareblastersetup33.exeCWShredder;shredder.log;http://cwshredder.net/bin/CWSInstall.exeBugOff;bugoff.log;http://computercops.biz/zx/Merijn/bugoff.zipHijackThis;hjt.log;http://downloads.subratam.org/hijackthis.zipProcessExplorer;procexp.log;http://www.sysinternals.com/files/procexpnt.zipWMPScriptFix;wmpfix.log;http://www.wilderssecurity.net/downloads/WMPscriptfix.exe 5.) Run script or schedule it Using script is now quite easy - just run update.bat with parameter (parameter means the name of category to check), for example "Update Spyware" will check/download all files in spyware.ini. Any comments, recommendations etc. STRONGLY invited! Hope so you enjoy....Could anyone post their ini files? I am specially interested in files for SysInternals
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now