32 replies
The best (and easiest) way to do this would be to write it in script as opposed to batch. You technically COULD do it in batch if you used FIND to find each condition (maybe a line number) so that you could grab each unique ID. Otherwise, I do notbelieve you can use batch to read a file in the manner you need.
With script you could then use an if..then..else statement or a FOR loop for each time you need to run those commands.
by robbinsr
by robbinsr
by robbinsr
This was started (Can anyone fix the errors or correct it?)
REM: Step 1. Call items from host list in order to be passed to Step 2.
:Call
FOR %%X IN (#:\#####\Hostlist.txt) DO CALL :Perform
REM: Step 2. Perform DAT Update & Registry Update & Pass to Step 3.
:Perform
DO #:\*.dat -y -y
DO #:\*.reg -y -y
CALL :LOG
REM: Step 3. Log Successful & Unsuccessful attempts of the Perform Process & proceed to step 4.
:Log
REM: Terminate Program
:END
END
by shanghai sam
Please some details. I have some suggestions but I want to know:
-you need to use a list of ID's or you can run the batch file on all conputers? Any restrictions/exclusions?
-you run the same batch for all computers?
-with and what you mean. What execute the batch in fact (registry update)?
by robbinsr
by robbinsr
by robbinsr
UPDATED.....
REM Step 1. Call items from host list in order to be passed to Step 2.
:Call
FOR %%X IN (HOSTLIST) DO CALL :Perform
REM Step 2. Perform DAT Update & Registry Update & Pass to Step 3.
:Perform
D:\*xdat.exe [/LOGFILE DATUPD.txt][/SILENT][/F]
PAUSE
PAUSE
D:\*.reg -y -y
CALL :LOG
REM Step 3. Log Successful & Unsuccessful attempts of the Perform Process & proceed to step 4.
:Log
REM Terminate Program
:END
END
by gigelul
REM Step 1. Call items from host list in order to be passed to Step 2.
:Call
FOR %%X IN (#:\#####\Hostlist.txt) DO CALL :Perform
CALL: REPORT
REM Step 2. Perform DAT Update & Registry Update & Pass to Step 3.
:Perform
DO #:\*.dat -y -y
DO #:\*.reg -y ?y
REM if failed go to :LogF
CALL :LogS
REM Step 3. Log Successful & Unsuccessful attempts of the Perform Process & proceed to step 4.
REM Log successful events
:LogS
logevent.exe ?m \\LogServer ?s S ?e 60000 ?batch executed?
REM ?back to..?
REM Log failed events
:LogF
logevent.exe ?m \\LogServer ?s F ?e 65000 ?batch failed?
REM ?back to..?
REM Step4. Create report
:REPORT
dumpel.exe ?f batchrep.txt ?s \\LogServer ?l application ?m ?user event? ?e 60000 65000 -t
REM: Terminate Program
:END
END
(logevent.exe and dumpel.exe are from resource kit)
by gigelul
About line:
REPORT can be other batch file
by gigelul
Also maybe is an easy way to use CALL "batch file" for and .
If I have more time I will post other suggestions.
Hope this help you
by gigelul
by gigelul
Cut/paste don't work very well, not all "?" must be replaced with "-".
Exceptions:
?batch executed? replace with "batch executed"
?batch failed? replace with "batch failed"
?user event? replace with "user event"
by gigelul
by gigelul
Yesterday I see other question from you with same subject. Today I can't find again. I'm not sure that you see the batch posted as answer to this second question.
This is inspired from scripts posted by rentcook@excite.com
------------------------------------------
net use v: \\LogServer\virus$ /yes
if exist "c:\vupdate" goto :next
md "c:\vupdate"
: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\march16.txt" goto :OK
GOTO:UPDATE
:UPDATE
deltree /y "c:\vupdate\*.*"
copy v:\march16.txt c:\vupdate
copy v:\vupdate.exe c:\vupdate
cls
start "c:\vupdate\vupdate.exe"
v:\logevent.exe-m \\LogServer -s S -e 60000 "virus list updated"
GOTO :END
:OK
v:\logevent.exe -m \\LogServer -s S -e 61000 "no update necessary"
GOTO :END
:FAILED
v:\logevent.exe -m \\LogServer -s F -e 62000 "no antivirus program find"
:END
net use v: /delete
exit
------------------------------------------
To obtain a report use this in separate batch
dumpel.exe -f batchrep.txt -s \\LogServer -l application -m "user event" -e 60000 61000 62000 -t
About workstation ID: the batch will be replicated to all workstation and report batch will give you also the name of the computer which executed the updates. The update will be executed only one time/computer. Also the computer which don't have the path "C:\Program Files\Network Associates\McAfee VirusScan\Avconsol.exe" will not be updated (you can put here other condition to exclude some computer and updates will be executed only on computers from your hostlist)
by gigelul
If I understand correct what said Joseph, now you have 2 or 3 batch files likes these:
--------------------------------------------------
1.NEXTID.BAT
--------------------------------------------------
@ echo off
cls
for /f "tokens=1" %%X in(hostlist.txt) do call UPDATE.BAT %%X
exit
--------------------------------------------------
2.UPDATE.BAT
--------------------------------------------------
@ echo off
cls
??????????????????????????????????????????????????
Use variablepassed from previous bat (NEXTID.BAT). How?
??????????????????????????????????????????????????This will change all the rest of batch
??????????????????????????????????????????????????
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 :END
: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
:END
net use v: /delete
exit
--------------------------------------------------
3.REPORT.BAT
--------------------------------------------------
dumpel.exe -f batchrep.txt -s \\HomeServer -l application -m "User Event" -e 60000 61000 62000 -t
exit
by robbinsr
by robbinsr
by robbinsr
REM Step 1. Call items from host list in order to be passed to Step 2.
:Call
FOR %%X IN (#:\#####\Hostlist.txt) DO CALL :Perform
CALL: REPORT
REM Step 2. Perform DAT Update & Registry Update & Pass to Step 3.
:Perform
DO #:\*.dat -y -y
DO #:\*.reg -y -y
REM if failed go to :LogF ~~~"is this correct?"~~~
CALL :LogS
REM Step 3. Log Successful & Unsuccessful attempts of the Perform Process & proceed to step 4.
REM Log successful events
:LogS
logevent.exe -m \\LogServer -s S -e 60000 "batch executed"
:Report
REM Log failed events
:LogF
logevent.exe ?m \\LogServer -s F -e 65000 "batch failed"
:Report
REM Step4. Create report
:REPORT
dumpel.exe -f batchrep.txt -s \\LogServer -l application -m "user event" -e 60000 65000 -t
:END
REM Terminate Program
:END
END
by robbinsr
REM Step 1. Call items from host list in order to be passed to Step 2.
:Call
FOR %%X IN (#:\#####\Hostlist.txt) DO CALL :Perform
CALL: REPORT
REM Step 2. Perform DAT Update & Registry Update & Pass to Step 3.
:Perform
DO #:\*xdat.exe (superDAT release from McAfee.com for version 4.x)
DO #:\*.reg -y -y
REM if failed go to :LogF
CALL :LogS
REM Step 3. Log Successful & Unsuccessful attempts of the Perform Process & proceed to step 4.
REM Log successful events
:LogS
logevent.exe -m \\LogServer -s S -e 60000 "batch executed"
:Report
REM Log failed events
:LogF
logevent.exe ?m \\LogServer -s F -e 65000 "batch failed"
:Report
REM Step4. Create report
:REPORT
dumpel.exe -f batchrep.txt -s \\LogServer -l application -m "user event" -e 60000 65000 -t
:END
REM Terminate Program
:END
END
by robbinsr
by joseph moore
I have the solution for the first part of this. So, you have "host list containing a list of the unique id's on the network." Does that mean you have a text file full of machine names? I am gonna assume so.
So, say you have HOSTNAME.TXT that is comprised of a column of data like this:
STATION1
STATION2
STATION3
etc.
You get the point. Ok. Now, you want to read the text file, pull out each hostname from the file, and run several processes against each piece of data from HOSTNAME.TXT.
Am I on the right track? I hope so.
Here is what you do.
1) create a BAT file, call it PROCESS1.BAT and have it contain the following text:
@ echo off
cls
for /f "tokens=1" %%X in (list.txt) do call file2.bat %%X
exit
by joseph moore
Now, make a 2nd BAT file, call it FILE2.BAT and it can contain the following:
@ echo off
cls
@echo Hi there %1
@echo This is how you get this to work with a list of stuff!
@echo YOu can do as many steps as you want this way, all with the variable set
@echo Add all subprocedures and such.
That is it, really!
by joseph moore
So, to run this, put both BAT files along with the HOSTNAME.TXT file in the same directory, then just run PROCESS1.BAT and let it fly!
If you make changes or make a new HOSTNAME.TXT file, the BAT structure can stay the same.
Now, I saw this question, and I though there should be an easy way to read from a text file, and pass the parameters to other functions. Well the FOR command can do that, and it passes the values into the variable you set with it; that is standard FOR command syntax. 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, but I just don't know how!
But it hit me tonight, as I was riding the train home (and listening to some Goth Metal bands) that the FOR command will pass each variable value to a ECHO statement for screen output; and if you can get a screen image, you can send THAT value to ANOTHER BAT file, using the reserved variables %1, %2, etc.
That was when I realized that that is the solution for your question.
Now, to be honest, I have not even thought about the error logging you want to do if the updates you are running fail, but from the looks of the posts, you have that under control.
So, in the 2nd BAT file, where I posted a few ECHO lines, just replace them with calling the updates and REG changes, plus the rest of the logging the other answers have set up.
hope this helps
by joseph moore
Forgot to mention, it looks like the 2 BAT file method handles Step 1 for you, just to be clear.
And I was listening to Theatre of Tragedy, Type O Negative, and Lacuna Coil for inspiration on this!
by joseph moore
I also forgot to mention (just to be clear) that in FILE2.BAT, use %1 as the variable when you need the passed data from the text file. So, to log to a file in the successful section that machine STATION2 was successful, you could do something like:
ECHO %1 was successful >>successful.txt
And in the text log file, you would have:
STATION2 was successful
Good luck on this!
by robbinsr
by robbinsr
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
: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 :END
: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
:END
call report.bat
net use v: /delete
exit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hostlist.Bat Contents For Review
@echo off
cls
@echo %1 010:1743
@echo %2 010:1744
@echo %3 010:1752
@echo %4 010:2020
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
Report.Bat Contents For Review
dumpel.exe -f batchrep.txt -s \\HomeServer -l application-m "User Event" -e 60000 61000 62000 -t
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
by robbinsr
THIS IS WHERE I STAND, PLEASE ANY FINAL SUGGESTIONS CORRECTIONS.. YOU WILL BE REWARDED SHORTLY. ONCE THIS RUNS, and COMPLETES... I WILL CLOSE THIS QUESTION and YOU WILL GET SOME POINTS...... THANX MUCH GUYS.....
: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 :END
: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
:END
call report.bat
net use v: /delete
exit
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hostlist.Bat Contents For Review
@echo off
cls
@echo %1 010:1743
@echo %2 010:1744
@echo %3 010:1752
@echo %4 010:2020
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
Report.Bat Contents For Review
dumpel.exe -f batchrep.txt -s \\HomeServer -l application -m "User Event" -e 60000 61000 62000 -t
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
by robbinsr
ALMOST THERE GUYS.... if you need to contact me (robbinsr@pweh.com).... Thanks much!!!!!!!!!!! Here is another UPDATE.....
X~!X~!
: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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hostlist.Bat Contents For Review
@echo off
cls
@echo %1 010:1743
@echo %2 010:1744
@echo %3 010:1752
@echo %4 010:2020
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
Report.Bat Contents For Review
dumpel.exe -f batchrep.txt -s \\HomeServer -l application -m "User Event" -e 60000 61000 62000 -t
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
X~!X~!
by robbinsr
: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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Hostlist.Bat Contents For Review
@echo off
cls
@echo %1 010:1743
@echo %2 010:1744
@echo %3 010:1752
@echo %4 010:2020
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
Report.Bat Contents For Review
dumpel.exe -f batchrep.txt -s \\HomeServer -l application -m "User Event" -e 60000 61000 62000 -t
{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
by robbinsr
This discussion is closed to new replies.
Trending Windows Forum posts
Sort by Trending