Solved

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

Posted on 2006-10-30
3
453 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

17 Experts available now in Live!

Get 1:1 Help Now