Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
the proplem is i can not seem to find any info on how to nest a 2nd
for /f loop command to grab a 2nd set of information. mainly i want to grab
the
scopes IP and the scope name from a premade list in a txt file. while using a
batch file with all the commands to add scopes in to dhcp.i have 99% of everything working great. here is my batch file. i am sure it
is ugly but it was my 1st real try.
it does almost everything right. id like to grab data from one txt file
containing the scopes ips 192.168.1, 192.168.2 ect.. and to grab the scope
names from another txt file containing scope1, scope2, ect.the below batch file will grab the scope ip addresses from a txt file.
if i try to combine 2 for /f loops i get some stuff but it is never works
the way i need it to.set w=.1
set x=.0
set z=.100
set y=.254
set serverscope=serverscope.txtFOR /f "tokens=*" %%M in (%serverscope%) do CALL :CHECK "%%M"
GOTO :EOF
:CHECK
SET serverscope=%~1
SET serverscope=%serverscope: =%set dhcpserver=dhcpserver1
set ip=%serverscope%
set scope=%ip%%x%
set scopename=%name%
set description=%username%_02/12/07
set iprange_exclude=%ip%%z% %ip%%y%
set router=%ip%%w%
set subnet=255.255.255.0netsh dhcp server \\%dhcpserver% add scope %scope% %subnet% %scopename%
%description%
netsh dhcp server \\%dhcpserver% scope %scope% add iprange %iprange_exclude%
netsh dhcp server \\%dhcpserver% scope %scope% add excluderange
%iprange_exclude%
netsh dhcp server \\%dhcpserver% scope %scope% set optionvalue 51 dword
2592000
netsh dhcp server \\%dhcpserver% scope %scope% set optionvalue 003 ipaddress
%router%
netsh dhcp server \\%dhcpserver% scope %scope% set state 1

Repost this in the programming section and M2 or IVO will help you out.
"Computer security." — Oxymoron

![]() |
DHCP setup..................
|
disabling removable devic...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |