Solved

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

Posted on 2006-10-30
3
487 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
[X]
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
  • 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 96

Expert Comment

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

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

0
 
LVL 96

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

696 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