Discussion Locked

Batch File Assitance

0 helpful
17 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
The last question was getting really messy. I thought we would clean it up some. Here is the current status of my batch file. I created this batch file to run off a server, call every machine from a list and up date the dat files, and a registry edit, and log the events. Please add any comments or suggestions. Thanks For The Help....

17 replies

by robbinsr

Main Batch File:

:Call
@ echo off
cls
for /f "tokens=1" %%x in (hostlist.txt) do call hostlist.bat
goto :Perform

:Perform
net use v:\\HomeServer\Virus$ /Yes
if exist "C:\vupdate" goto :NEXT
md "c:\vupdate" goto :NEXT

:NEXT
if exist "c:\vupdate\vupdate.exe" deltree /y "c:\vupdate\vupdate.exe"
cls
if not exist "C:\Program Files\Network Associates\McAfee VirusScan\Avconsol.exe" goto :FAILED
if exist "C:\vupdate\MonthDay.txt" goto :OK
goto :UPDATE

:UPDATE
deltree /y "c:\vupdate\*.*"
copy v:\\HomeServer\MonthDay.txt C:\vupdate
copy v:\\HomeServer\vupdate.exe C:\vupdate
cls
start "c:\vupdate\vupdate.exe"
v:\Logevent.exe -m \\HomeServer -s S -e 60000 "AntiVirus DAT Updates Complete"
goto :REG

:OK
v:\logevent.exe-m \\HomeServer -s S -e 61000 "AntiVirus DAT Update Resides on Drive"
goto :END

:FAILED
v:\logevent.exe -m \\HomeServer -s F -e 62000 "Missing AVCONSOL.EXE"
goto :END

:REG
if exist "c:\vupdate\*.reg" goto :REGRESIDES
copy v:\\HomeServer\*.reg c:\vupdate\*.reg
start "c:\vupdate\*.reg -y -y"
goto :REGLOG

:REGRESIDES
v:\Logevent.exe -m \\HomeServer -s S -e 61000 "Registry Edit Resides on Drive"
goto :END

:REGLOG
v:\Logevent.exe -m \\HomeServer -s S -e 60000 "Registry Has Been Updated"
goto :END

:END
call report.bat
net use v: /delete
exit

by robbinsr

Hostlist.Bat Contents For Review

@echo off
cls
@echo %1 010:1743
@echo %2 010:1744
@echo %3 010:1752
@echo %4 010:2020

by robbinsr

Report.Bat Contents For Review

dumpel.exe -f batchrep.txt -s \\HomeServer -l application -m "User Event" -e 60000 61000 62000 -t

by timthetoolman

Hi,

I think the following should do what you want. You need to fill out the bits as suggested in the comments in the batch file. Its a single batch file solution that calls itself and the existance of a parameter determines whether it is the initial call or the call to do "real work".

Cheers,
Tim.

rem updatehosts.bat

echo off
if /I "%1" NEQ "" goto perform_op
for /f "tokens=1" %%i in (hostlist.txt) do call updatehosts.bat %%i
goto end

:perform_op
echo doing it for %1

rem - put your update specific stuff here and when you need
rem - to refer to the host name, use %1 instead.

rem - Also as some of the other answers stated, when you run
rem - each command be sure to use the command >> logfile so
rem - that you append the logs from all the output.

rem - Automatically analysing that log file for errors afterwards
rem - is another problem entirely....

:end

-----------------

hostlist.txt

nodea
nodeb
nodec

etc....

by shanghai sam

Hi,

Well, its the solution. Remember the quote from Joseph...?

"But the problem I had was trying to figure out how to keep the variable set on a separate line AFTER the FOR line within the same BAT file.
And I just could not figure it out. Maybe someone out there can do it"

This, I believe (if I understand what you want correctly...) is that solution. A single bat file that reads and processes each entry in the hostlist file. It "holds the variable to the next line" by calling itselfwith those parameters. You'll see how it works by looking at it. The bits I've added are only quite short. It must be called updatehosts.bat

I'll cut and paste your bits in if you like...

...continued...

by timthetoolman

Hi,

Well, its the solution. Remember the quote from Joseph...?

"But the problem I had was trying to figure out how to keep the variable set on a separate line AFTER the FOR line within the same BAT file.
And I just could not figure it out.Maybe someone out there can do it"

This, I believe (if I understand what you want correctly...) is that solution. A single bat file that reads and processes each entry in the hostlist file. It "holds the variable to the next line" by calling itself with those parameters. You'll see how it works by looking at it. The bits I've added are only quite short. It must be called updatehosts.bat

I'll cut and paste your bits in if you like...

...continued... (sorry about the double post)

by timthetoolman

echo off
if /I "%1" NEQ "" goto perform_op
for /f "tokens=1" %%i in (hostlist.txt) do call updatehosts.bat %%i
goto end

:perform_op
net use v:\\HomeServer\Virus$ /Yes
if exist "C:\vupdate" goto :NEXT
md "c:\vupdate" goto :NEXT

:NEXT
if exist "c:\vupdate\vupdate.exe" deltree /y "c:\vupdate\vupdate.exe"
cls
if not exist "C:\Program Files\Network Associates\McAfee VirusScan\Avconsol.exe" goto :FAILED
if exist "C:\vupdate\MonthDay.txt" goto :OK
goto :UPDATE

:UPDATE
deltree /y "c:\vupdate\*.*"
copy v:\\HomeServer\MonthDay.txt C:\vupdate
copy v:\\HomeServer\vupdate.exe C:\vupdate
cls
start "c:\vupdate\vupdate.exe"
v:\Logevent.exe -m \\HomeServer -s S -e 60000 "AntiVirus DAT Updates Complete"
goto :REG

:OK
v:\logevent.exe -m \\HomeServer -s S -e 61000 "AntiVirus DAT Update Resides on Drive"
goto :END

:FAILED
v:\logevent.exe -m \\HomeServer -s F -e 62000 "Missing AVCONSOL.EXE"
goto :END

:REG
if exist "c:\vupdate\*.reg" goto :REGRESIDES
copy v:\\HomeServer\*.reg c:\vupdate\*.reg
start "c:\vupdate\*.reg -y -y"
goto :REGLOG

:REGRESIDES
v:\Logevent.exe -m \\HomeServer -s S -e 61000 "Registry Edit Resides on Drive"
goto :END

:REGLOG
v:\Logevent.exe -m \\HomeServer -s S -e 60000 "Registry Has Been Updated"
goto :END

:END
call report.bat
net use v: /delete
exit

...continued...

by timthetoolman

But looking carefully at the procedure that florinel supplied originally, it looks like that might be a client script rather than a server one.

I think you need to be sure about what actual commands you need to perform for each host name from thehostlist.txt file.

And more the point, where they are to be performed... ie. on the server or on the client.

ie. What exactly did you originally mean by...

REM: Step 2. Perform DAT Update & Registry Update & Pass to Step 3.
:Perform
DO #:\*.dat -y -y
DO #:\*.reg -y -y
CALL :LOG

Is your current solution running at all? It doesn't look like it's going to do what you want...

Cheers,
Tim.

by robbinsr

If I fill in the blanks will this RUN correctly? Your opinions on why not, if you belive it will not RUN... I need to finish this ASAP. This has gone far past my personal ability so I am counting on your help to finish...

:Call
@ echo off
cls
if /I "%1" NEQ "" goto perform_op
for /f "tokens=1" %%i in (hostlist.txt) do call hostlist.bat %%i
goto :Perform

:Perform
net use v:\\HomeServer\Virus$ /Yes
if exist "C:\vupdate" goto :NEXT
md "c:\vupdate" goto :NEXT

:NEXT
if exist "c:\vupdate\vupdate.exe" deltree /y "c:\vupdate\vupdate.exe"
cls
if not exist "C:\Program Files\Network Associates\McAfee VirusScan\Avconsol.exe" goto :FAILED
if exist "C:\vupdate\MonthDay.txt" goto :OK
goto :UPDATE

:UPDATE
deltree /y "c:\vupdate\*.*"
copy v:\\HomeServer\MonthDay.txt C:\vupdate
copy v:\\HomeServer\vupdate.exe C:\vupdate
cls
start "c:\vupdate\vupdate.exe"
v:\Logevent.exe -m \\HomeServer -s S -e 60000 "AntiVirus DAT Updates Complete"
goto :REG

:OK
v:\logevent.exe -m \\HomeServer -s S -e 61000 "AntiVirus DAT Update Resides on Drive"
goto :END

:FAILED
v:\logevent.exe -m \\HomeServer -s F -e 62000 "Missing AVCONSOL.EXE"
goto :END

:REG
if exist "c:\vupdate\*.reg" goto :REGRESIDES
copy v:\\HomeServer\*.reg c:\vupdate\*.reg
start "c:\vupdate\*.reg -y -y"
goto :REGLOG

:REGRESIDES
v:\Logevent.exe -m \\HomeServer -s S -e 61000 "Registry Edit Resides on Drive"
goto :END

:REGLOG
v:\Logevent.exe -m \\HomeServer -s S -e 60000 "Registry Has BeenUpdated"
goto :END

:END
call report.bat
net use v: /delete
exit

by robbinsr

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hostlist.Bat Contents For Review

@echo off
cls
001:1234
002:3456
003:4567
004:5678
005:6789
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
Report.Bat Contents For Review

dumpel.exe -f batchrep.txt -s \\HomeServer -l application -m "User Event" -e 60000 61000 62000 -t
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}

by robbinsr

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

TIM:

I want it to RUN off the server, CALL each CLIENT, RUN the update ON each client, andSEND the REPORT back to the server. do not worry about the dat or reg. they were generic syntax.

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

by gigelul

On your first question you don?t mentioned that you want a server script.
Tim observes correct that my first post was a client script.
Also you tell me that you want to perform an antivirus update. I don?t use McAfee but your *.DAT file I think that is designed to be run locally on computer. Be carefully from where and who (server or workstation) launch the update. The results can be a continuous update of the server.
If I understand correct your issue you must make some changes in batch to run it from server.

This discussion is closed to new replies.