Solved

in VB6 changing IP adres Windows XP

Posted on 2013-05-11
4
498 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 45

Accepted Solution

by:
aikimark earned 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

705 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

20 Experts available now in Live!

Get 1:1 Help Now