Solved

VBSCRIPT To change Ipconfiguration to Obtain an IP address automatically

Posted on 2012-12-27
8
1,729 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
powershell code to list items in dropdown 6 60
Internet Protocol Security question 3 67
VB.net and sql server 4 33
Multiple MPLS Circuits Connecting to LAN 3 24
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

786 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