Solved

in VB6 changing IP adres Windows XP

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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to parse out a json string in VB6? 10 167
vb6 connector to SQL Server 2 37
how to know if my Checkbox is True in VB6.0? 9 55
Way to decrease size of apk file 9 67
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This video teaches viewers about errors in exception handling.
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.

773 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