Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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