Solved

VBSCRIPT To change Ipconfiguration to Obtain an IP address automatically

Posted on 2012-12-27
8
1,830 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Make the most of your online learning experience.
Introduction to Processes
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

695 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