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
Solved

in VB6 changing IP adres Windows XP

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 105
vbModal 12 57
Capture logon name 13 87
Export PDF Form fields to Access  or Excel  in Tab order 16 79
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
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 tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

856 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