Solved

Batchscript that will look in a file to retrieve server names...

Posted on 2006-10-30
3
442 Views
Last Modified: 2008-02-01
How can I run this batchscript that will look in a file for server names rather than using the for loop?




for %%J in ( Server1 Server2 ) do CALL :copynext %%J
goto :Finished


:copynext
:: %1 comes from the call line, not the command line
set srvnme=%1

ECHO.
ECHO Running Dumpsec: %srvnme%
@echo off
ping -n 10  \\127.0.0.1 >NUL

@echo on
dumpsec /rpt=rights /saveas=csv /outfile=%srvnme%.txt /computer=%srvnme%

@echo off



:exit
goto :EOF


:Finished
0
Comment
Question by:mystikal1000
  • 2
3 Comments
 
LVL 10

Expert Comment

by:GuruGary
ID: 17836543
You can use a FOR /F loop.

If all of your server names are in the file SERVERNAMES.TXT you can do:
for %%J in (SERVERNAMES.TXT) do CALL :copynext %%J
0
 
LVL 95

Expert Comment

by:Lee W, MVP
ID: 17836552
You mean:

for /f "Tokens=1" %%a in (filename.ext) Do call :copynext %%a

0
 
LVL 95

Accepted Solution

by:
Lee W, MVP earned 500 total points
ID: 17836581
OF course, I'd probably just condense the whole script:

@echo off
for /f "tokens=1" %%a in (serverlist.txt) do (
    Echo.
    Echo Running Dumpsec: %%a
    Ping -n 10 \\127.0.0.1 >NUL
    @echo On
    dumpsec /rpt=rights /saveas=csv /outfile=%%a.txt /computer=%%a
    @echo off
)
   
   
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now