Jump to content

Recommended Posts

Posted

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:

WGET

Tfind

2.) 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=on
boolProxy=on
http_proxy=http://proxy.domain.com:80
LogDirectory=\\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.vbs

update.bat:

@echo off
If "%1" EQU "" Echo You must provide parameter with update group! && Goto :EOF
Set UpdateGroup=%1
Title %UpdateGroup% updating
Set MainDirectory=%cd%
If not exist "%MainDirectory%\Update.ini" Echo Missing Update.ini file!!! && Pause && Goto :EOF
For /f "usebackq tokens=1,2 delims==" %%i IN (`type "%MainDirectory%\Update.ini"`) DO Set %%i=%%j

If not exist "%MainDirectory%\%UpdateGroup%" mkdir "%MainDirectory%\%UpdateGroup%"
cd %UpdateGroup%

Echo Removing log files
If Exist "%LogDirectory%\%UpdateGroup%\Details" rmdir /q /s "%LogDirectory%\%UpdateGroup%\Details"

Echo Removing error log
If Exist "%LogDirectory%\%UpdateGroup%\error.log" del /q "%LogDirectory%\%UpdateGroup%\error.log"

Echo Creating log directory
mkdir "%LogDirectory%\%UpdateGroup%\Details"

Echo Creating temp file for case where nothing is updated
echo. > "%MainDirectory%\%UpdateGroup%\working.txt"

FOR /F "tokens=1,2,3,4 delims=; " %%i in (..\%UpdateGroup%.ini) do call ..\internal-Download.bat %%i %%j %%k

If exist "%MainDirectory%\%UpdateGroup%\working.txt" echo %date:~3,11%;No newer versions available >> "%LogDirectory%\%UpdateGroup%\aktualizacie.log"
pause

internal-Download.bat:

@echo off

rem %1 = Product name
rem %2 = Log file name
rem %3 = URL address

Echo Downloading %1
wget --timestamping --output-file="%2" --server-response --proxy=%boolProxy% %3
call tfind.com /e "Saved" %2
set 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" %2
set 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.2004

Option Explicit
On Error Resume Next

Dim objArguments, objNamed

set objArguments  = WScript.Arguments
set objNamed = WScript.Arguments.Named

Call OdoslanieMailu
Set objShell = Nothing

Wscript.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 = Nothing
End Sub

4.)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 link

For example my Spyware.ini file:

KillBits;killbit.log;http://www.spywareguide.com/blocklist.reg
RestrictedSites;restrict.log;https://netfiles.uiuc.edu/ehowes/www/res/ie-spyad.zip
RestrictedSites2;rest2.log;https://netfiles.uiuc.edu/ehowes/www/res/ie-spyad2.zip
Spybot;spybot.log;http://www.spybotupdates.com/updates/files/spybotsd_includes.exe
SpywareBlaster;blaster.log;http://securityhelpers.net/downloads/spywareblastersetup33.exe
CWShredder;shredder.log;http://cwshredder.net/bin/CWSInstall.exe
BugOff;bugoff.log;http://computercops.biz/zx/Merijn/bugoff.zip
HijackThis;hjt.log;http://downloads.subratam.org/hijackthis.zip
ProcessExplorer;procexp.log;http://www.sysinternals.com/files/procexpnt.zip
WMPScriptFix;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


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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...