Solved

in VB6 changing IP adres Windows XP

Posted on 2013-05-11
4
523 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
[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
  • 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 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
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…

632 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