mystikal1000
asked on
Batchscript that will look in a file to retrieve server names...
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
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
You mean:
for /f "Tokens=1" %%a in (filename.ext) Do call :copynext %%a
for /f "Tokens=1" %%a in (filename.ext) Do call :copynext %%a
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If all of your server names are in the file SERVERNAMES.TXT you can do:
for %%J in (SERVERNAMES.TXT) do CALL :copynext %%J