Solved

VBSCRIPT To change Ipconfiguration to Obtain an IP address automatically

Posted on 2012-12-27
8
1,784 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Use of TCL script on Cisco devices:  - create file and merge it with running configuration to apply configuration changes
I had an issue with InstallShield not being able to use Computer Browser service on Windows Server 2012. Here is the solution I found.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 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