Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Script help please

Thread Tools
 
Search this Thread
 
Old 20 January 2003, 09:44 AM
  #1  
dogmaul
Scooby Regular
Thread Starter
 
dogmaul's Avatar
 
Join Date: Nov 2001
Posts: 1,437
Likes: 0
Received 0 Likes on 0 Posts
Post

Can anyone spot any problems with this script ??
It was written for me by a friend but it seems to be causing problems with our fax software.

thanks mike


@echo off
::-----------------------------------------------------
:: Multipurpose antivirus update script.
:: Written by Richard Parvass 26/06/02
:: Current version: 1.2
:: Modifications:
:: 26/06/02 - 1.0 - RSP - Initial version
:: 17/10/02 - 1.1 - RSP - Updated WGET to 1.9
:: --------------------------- Added bandwidth option
:: --------------------------- Added alerts to adminuser
:: --------------------------- Added download dat.zip by default
:: 05/11/02 - 1.2 - RSP - Changed alerting to allow SMTP, Net Send, MAPI
::-----------------------------------------------------

setlocal
set runfrom=%~sdp0\..\
set name=%~n0
set nameext=%~nx0
if not exist %runfrom%\%nameext% set runfrom=%~sdp0\

::-----------------------------------------------------
:: Set up specifics here - see documentation for info
::-----------------------------------------------------
set useras=no
set rascon=bsdial.net
set rasuser=
set raspass=
set useproxy=no
set proxyuser=
set proxypass=
set passiveftp=yes
set ftp_proxy=10.0.0.2:1080
set wgetparam=
set bandwidth=20k
::-----------------------------------------------------
:: Alerting information
::-----------------------------------------------------
set AlertType=smtp,send
set senduser
set emailto=
set emailcc=
set emailfrom=
set MAPIprofile=
set MAPIpwd=
set SMTPserver=
set site=
::-----------------------------------------------------
:: Default NAI directories - should not need modifying
::-----------------------------------------------------
set dats=ftp://ftp.nai.com/pub/antivirus/datfiles/4.x/
set engine=ftp://ftp.nai.com/pub/antivirus/engine/4.x/
::-----------------------------------------------------

if "%1"=="" goto :usage

if defined bandwidth set bandwidth=--limit-rate=%bandwidth%
set wgetparam=%wgetparam% --no-parent --no-directories --mirror %bandwidth%
if defined proxyuser (set proxyuser=--proxy-user=%proxyuser%) else (set proxyuser= )
if defined proxypass (set proxypass=--proxy-passwd=%proxypass%) else (set proxyuser= )
if /I "%passiveftp%" NEQ "yes" (set passiveftp= ) else (set passiveftp=--passive-ftp)
if /I "%useproxy%" NEQ "yes" (set useproxy= &set ftp_proxy=) else (set useproxy=--proxy=on %proxyuser% %proxypass%)


opvars
if "%1"=="" goto :donevars
if /I "%1" EQU "linux" set linux=1&goto :nextvar
if /I "%1" EQU "netware" set netware=1&goto :nextvar
if /I "%1" EQU "palm" set palm=1&goto :nextvar
if /I "%1" EQU "windows" set windows=1&goto :nextvar
if /I "%1" EQU "/d" set dldir=%2&shift 1&goto :nextvar
goto :usage

:nextvar
shift 1
goto opvars

:donevars
if not defined dldir call :setdir
if "%dldir%"=="" echo No download directory determined!&goto :usage
if not exist %dldir%\*.upd for /f %%i in ('dir /s/b %dldir%\*.upd') do set dldir2=%%~dpi
if defined dldir2 set dldir=%dldir2%

echo Download directory set as: %dldir%

if /I "%useras%" NEQ "yes" goto :rasok
set rasloop=0
:rasloop
set /a rasloop=%rasloop%+1
rasdial %rascon% %rasuser% %raspass% >nul
if NOT ERRORLEVEL == 1 goto :rasok
set raserr=%errorlevel%
if "%raserr%"=="633" echo Link already established.&goto :rasok
if "%rasloop%" LEQ "5" echo Dial connection %rasloop% failed. Retrying.&goto :rasloop
echo Dial up connection failed too many times with error %raserr%.>>connect.log
goto :end

:rasok
if /I "%useras%" EQU "yes" for /l %%a in (1,1,5) do dir c:\ /s>nul

pushd %dldir%
attrib -r *.*
for /f %%i in ('dir sdat*.exe /b /ogd') do set currentsdat=%%i
if not defined currentsdat for /f %%i in ('dir dat*.zip /b /ogd') do set currentsdat=%%i

:: Make a backup copy of setup.exe and delete
if not defined windows goto :nowin1
copy setup.exe setup.old

:delete
del /f setup.exe
if exist setup.exe goto :delete


:nowin1
call :createscripts

if not defined windows goto :nowin2
:rename
for /f %%i in ('dir sdat*.exe /b /ogd') do set latestsdat=%%i
if not defined latestsdat goto :nosdatupdate
copy %latestsdat% setup.exe
echo Current: %currentsdat% Latest: %latestsdat%


if "%latestsdat%"=="%currentsdat%" goto :nosdatupdate
net send %senduser% SuperDAT updated from %currentsdat% to %latestsdat% in FTP directory
net send %computername% SuperDAT updated from %currentsdat% to %latestsdat% in FTP directory

:nosdatupdate
if not exist setup.exe copy setup.old setup.exe

:nowin2
echo [SuperDATOptions]>setup.iss
echo bReboot=1 >>setup.iss
echo bPrompt=1 >>setup.iss
echo szLogFile=\SuperDAT.LOG>>setup.iss

:sendalert
if not defined latestsdat for /f %%i in ('dir dat*.zip /b /ogd') do set latestsdat=%%i
if not defined latestsdat set latestsdat=*MISSING*
if "%latestsdat%" == "%currentsdat%" goto :noreport

set subj=Antivirus report for %site%:
if "%latestsdat%" == "*MISSING*" set msg=Latest version is missing&set subj=%subj% ERROR
if NOT "%latestsdat%" == "%currentsdat%" set msg=Version updated from %currentsdat% to %latestsdat%&set subj=%subj% OK

if exist "%temp%\av.msg" del "%temp%\av.msg"
echo %msg%>"%temp%\av.msg"

if defined AlertType for %%i in (%AlertType%) do call :alert%%i

:noreport
call :cleanup

:end
endlocal
goto :EOF

:alertsmtp
if defined emailcc set cc=-cc %emailcc%
%runfrom%\blat "%temp%\av.msg" -to %emailto% -s "%subj%" -f %emailfrom% %cc% -server %SMTPserver%
goto :EOF

:alertmapi
if defined emailcc set cc=-c %emailcc%
%runfrom%\mapisend -u %mapiprofile% -p %mapipwd% -r %emailto% -s "%subj%" -t "%temp%\av.msg" %cc%
goto :EOF

:alertsend
net send %senduser% %subj% %msg%
net send %computername% %subj% %msg%
goto :EOF

:cleanup
if /i "%useras%" EQU "yes" rasdial %rascon% /disconnect >nul
goto :EOF

:setdir
for /f "tokens=3 delims=, " %%i in ('%runfrom%\reg query "hklm\system\currentcontrolset\services\msftpsvc\p arameters\virtual roots\/" ^| find "/"') do set dldir=%%i
goto :EOF

:createscripts
%runfrom%\wget %wgetparam% %useproxy% %passiveftp% --accept *.[uU][pP][dD],[dD][aA][tT]*.[zZ][iI][pP] %dats%
for %%i in (windows linux netware palm) do if defined %%i call :scr%%i
goto :EOF

:scrwindows
%runfrom%\wget %wgetparam% %useproxy% %passiveftp% --accept *.[eE][xX][eE],*.[iI][nN][iI] %dats%
goto :EOF

:scrlinux
%runfrom%\wget %wgetparam% %useproxy% %passiveftp% --accept *.[tT][aA][rR] %dats%
%runfrom%\wget %wgetparam% %useproxy% %passiveftp% --accept [eE][lL][nN][xX]*[zZ][iI][pP] %engine%
goto :EOF

:scrnetware
%runfrom%\wget %wgetparam% %useproxy% %passiveftp% --accept *.[zZ][iI][pP] %dats%
%runfrom%\wget %wgetparam% %useproxy% %passiveftp% --accept [nN][wW]* %engine%
goto :EOF

:scrpalm
%runfrom%\wget %wgetparam% %useproxy% %passiveftp% --accept *.[zZ],*.[iI][nN][iI] %dats%
goto :EOF

:usage
echo Usage:
echo %name% ^<type^> [^<type^>...] [^</d^> ^<destinationdir^>]
echo Where TYPE is one of:
echo netware
echo linux
echo windows
echo palm
echo At least one type must be present. All other arguments are optional.
echo [^</d^> ^<destinationdir^>] is optional, but if a destination directory
echo cannot be determined, the script will exit. The script attempts to find
echo an FTP root directory to use as the destination directory, or a sub-
echo directory off the FTP root that contains .upd files.
goto :EOF
Old 20 January 2003, 12:26 PM
  #2  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

theres some much better ways of doing updates with network associates software, with out scripts and paying for avd..

Either do a search for kix and network associates

(some fancy kix scripts)

or configure 1 server to mirror ftp.nai.com/pub/antivirus/4.x

or whatever...

then configure machines to have autoupdate configured to point to this server, you can also use the installation designer to preconfigure the software package...

Mail me if its easier.

David

2000 + NAI user site.. (Running EPO now, but havent allways)
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
m18use
Computer & Technology Related
4
05 September 2002 09:00 PM
Ricochet
Computer & Technology Related
10
26 August 2002 07:02 PM



Quick Reply: Script help please



All times are GMT +1. The time now is 11:52 PM.