Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

856 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