Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

in VB6 changing IP adres Windows XP

Posted on 2013-05-11
4
Medium Priority
?
535 Views
Last Modified: 2013-05-12
I have a not managed by a person pc running some programs and send reports by mail to me
it will happen that some one connects on the network with a static (laptop eg) IP adres
my PC is willgo sometimes in connection error due to IP conflict caused with by this other device
My email routine will report to my VB6 program it lost connection
Now I only need a sub routine to renew my own IP adres to reconnect
0
Comment
Question by:BIAPRO
  • 2
4 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 39158115
The simplest solution will be to use a shell object to run the commands

ipconfig /release all
ipconfig /renew

Something like this

Sub RenewIP()
    Dim objShell As Object
    Set objShell = CreateObject("Wscript.Shell")
    objShell.Run "ipconfig /release all", , True
    objShell.Run "ipconfig /renew", , True
    Set objShell = Nothing
End Sub

Open in new window

0
 

Author Comment

by:BIAPRO
ID: 39158192
Ok, did set as test a pc to my IP adres, I will get the know error "conflict with other pc"
then  the command (tested from commandline )   will state at
ipconfig /release all   (enter)  (translated from dutch Windows)

"the command did not work since not a single network adapter is at a state do perform this command"  

My pc is not static on IP , so get a new one right?
0
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 total points
ID: 39159181
You will most likely get the one you just released. Only if someone else requests a sub-netted IP address will you get another address.  In a DHCP environment, addresses are pooled.

I think you might be able to assign a new IP address with a
netsh interface ip set address name=""Local Area Connection"" static
command.
http://technet.microsoft.com/en-us/library/bb490943.aspx

Here's an example of VB code doing this:
http://www.tek-tips.com/faqs.cfm?fid=4910

============
It might also be possible to use WMI (Win32_NetworkAdapterConfiguration class).  Be aware that the code examples are iterating through all the adapters on the system. You will probably want to restrict the looping to your main adapter.
0
 

Author Closing Comment

by:BIAPRO
ID: 39159192
THANKS
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

877 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