Solved

VBSCRIPT To change Ipconfiguration to Obtain an IP address automatically

Posted on 2012-12-27
8
1,679 Views
Last Modified: 2013-01-02
I found a batch file that resets the network adapter settings. Can someone please convert this to vbscript? Or if someone already has a solution? I need to change the TCP/IP settings to Obtain an IP address automatically and Obtain DNS server address automatically? Can someone please help.


Here is the batch file

@echo off
:prompt
color 1f
cls
echo NETWORK RESET SCRIPT

:test
cls
echo —————————————————-
echo - RELEASING IP…. -
echo —————————————————-
ipconfig /release >nul
echo.
echo Done!
echo.
echo —————————————————-
echo - RESETTING IP LOG… -
echo —————————————————-
@netsh int ip reset C:\Windows\TEMP\IPRESETLOG.txt >nul
echo.
echo Done!
echo.
echo —————————————————-
echo - FLUSHING ARP TABLES… -
echo —————————————————-
@arp -d >nul
echo.
echo Done!
echo.
echo —————————————————-
echo - FLUSHING DNS… -
echo —————————————————-
@ipconfig /flushdns >nul
echo.
echo Done!
echo.
echo —————————————————-
echo - RENEWING IP… -
echo —————————————————-
@ipconfig /renew >nul
echo.
echo Done!
echo.
cls
echo —————————————————-
echo Heres Your Status: -
echo —————————————————-
ipconfig /all
pause
echo.
cls
exit


Please help.
Vicki
0
Comment
Question by:Vicki05
8 Comments
 
LVL 8

Expert Comment

by:hpdvs2
ID: 38724936
I just searched your question's title on google and found this:
http://support.microsoft.com/kb/197424
 - switch to DHCP from VBScript.
0
 

Author Comment

by:Vicki05
ID: 38725099
I just tried it, it does not reset the ipconfiguration to automatic.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 38726525
Something like this?
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each objNetAdapter In colNetAdapters
	errEnable = objNetAdapter.EnableDHCP()
	If errEnable = 0 Then
		Wscript.Echo "DHCP has been enabled."
	Else
		Wscript.Echo "DHCP could not be enabled."
	End If
Next

Open in new window

There is also an EE thread dealing with this:
http://www.experts-exchange.com/Programming/Misc/Q_21368494.html
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 70

Accepted Solution

by:
KCTS earned 150 total points
ID: 38726548
does it need to be VBSCRIPT - the netsh command will do this (I suppose you could always call this from VB is you need to)

netsh interface ip set address "Local Area Connection" dhcp
0
 

Author Comment

by:Vicki05
ID: 38736283
Woolmilkporc I am getting an error that DHCP could not be enabled.


I am trying to use this on Windows 2000 and Windows XP systems.

I noticed that the batch file does not work on Windows 2000 either.

Please advice.

KCTS
Could you please show me how to put the command in a script?

netsh interface ip set address "Local Area Connection" dhcp
0
 

Author Comment

by:Vicki05
ID: 38738411
kCTS

KCTS

netsh interface ip set address "Local Area Connection" dhcp solution did work. I was able to convert it to vbscript.

Thanks for the suggestion.
Vicki
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now