Computing.Net > Forums > Windows Server 2003 > Dhcp Netsh batch help for /f cmd

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Dhcp Netsh batch help for /f cmd

Reply to Message Icon

Name: acem77
Date: February 13, 2007 at 07:33:12 Pacific
OS: server 2003
CPU/Ram: ?
Product: ?
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: February 16, 2007 at 10:22:51 Pacific
Reply:

Repost this in the programming section and M2 or IVO will help you out.

"Computer security." — Oxymoron


0
Reply to Message Icon

Related Posts

See More


DHCP setup.................. disabling removable devic...



Post Locked

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


Go to Windows Server 2003 Forum Home


Sponsored links

Ads by Google


Results for: Dhcp Netsh batch help for /f cmd

Batch script for copying files www.computing.net/answers/windows-2003/batch-script-for-copying-files/6487.html

FTP Batch Script for date filename www.computing.net/answers/windows-2003/ftp-batch-script-for-date-filename-/811.html

Help for DNS server in w2K3 server www.computing.net/answers/windows-2003/help-for-dns-server-in-w2k3-server/3218.html