General discussion

Locked

Batch File Assitance

By robbinsr ·
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....

This conversation is currently closed to new comments.

17 total posts (Page 1 of 2)   01 | 02   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Batch File Assitance

by robbinsr In reply to Batch File Assitance

Main Batch File:

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

erform
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 K
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

K
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

Collapse -

Batch File Assitance

by robbinsr In reply to Batch File Assitance

Hostlist.Bat Contents For Review

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

Collapse -

Batch File Assitance

by robbinsr In reply to Batch File Assitance

Report.Bat Contents For Review

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

Collapse -

Batch File Assitance

by TimTheToolMan In reply to Batch File Assitance

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

erform_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....

Collapse -

Batch File Assitance

by robbinsr In reply to Batch File Assitance

How would that fit into what I already have?

Collapse -

Batch File Assitance

by Shanghai Sam In reply to Batch File Assitance

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...

Collapse -

Batch File Assitance

by robbinsr In reply to Batch File Assitance

Poster rated this answer

Collapse -

Batch File Assitance

by TimTheToolMan In reply to Batch File Assitance

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)

Collapse -

Batch File Assitance

by TimTheToolMan In reply to Batch File Assitance

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

erform_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 K
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

K
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...

Collapse -

Batch File Assitance

by TimTheToolMan In reply to Batch File Assitance

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.
erform
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.

Back to Windows Forum
17 total posts (Page 1 of 2)   01 | 02   Next

Related Discussions

Related Forums