Networking Forums

Networking Forums > Computer Networking > Windows Networking > Dhcp Netsh batch file help for nesting two or more "for /f" loop c

Reply
Thread Tools Display Modes

Dhcp Netsh batch file help for nesting two or more "for /f" loop c

 
 
acem77
Guest
Posts: n/a

 
      02-13-2007, 01:56 PM
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.txt

FOR /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.0

netsh 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wireless adaptor disconnecting at night - how to batch the "repair"option? Jack \(MVP-Networking\). Wireless Networks 10 04-11-2008 09:37 AM
"Netsh Int show Int" always shows interfaces admin enabled Stockner Windows Networking 0 06-28-2005 08:18 PM
printk(KERN_CRIT "Dead loop on virtual device %s, fix it urgently!\n", dev->name); Jean-Pierre FORCIOLI Linux Networking 0 07-15-2004 08:50 PM
dhcp-client ignores "supersede" and "prepend" options Peter Klein Linux Networking 0 01-28-2004 12:21 AM
BT "rectified loop" fault ? Sunil Sood Broadband 47 08-28-2003 10:04 PM



1 2 3 4 5 6 7 8 9 10 11