RE: Determine if Virtual PC is running
- From: Kjell <Kjell@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 8 Sep 2007 13:28:02 -0700
Hi
I've just checked my source code and my code for PING actually derives from
a great example made by Randy Birch (VBnet)
so the right way to do this is:
URL: http://vbnet.mvps.org/index.html
look at / search for : "Ping a Machine by Host Name"
There are several examples on the subject for you to dig into.
Just bear in mind, there is no technical difference in sending a ping over
the internet, for ex. to "www.yahoo.com" or to a local PC with host name
"BossXP".
and... when pinging a local pc by host name, your DNS will translate the
host name into an IP-address and use that, any machine/equipment carrying
that IP-address will probably respond.
So, this is a code snipet for using WMI to verify that a certain machine
with IP-address has expected host name.
Private Sub DoMyAdvancedPing(Xhost)
Dim objWMIService
Dim colItems, objItem
Dim Hname As String
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & Xhost & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem")
For Each objItem In colItems
Hname = objItem.name & "" 'Host name
Next
Set objItem = Nothing
Set colItems = Nothing
Set objWMIService = Nothing
End Sub
You can set this up in two ways. if you're passing IP-address in Xhost,
Hname will give you the true host name for that machine.
If you're passing host name to be checked in Xhost, your DNS will once again
translate it into an IP-address, but the end is the same, Hname will show you
the true host name for that IP-address.
OBSERVE.... if the machine is down it will take something like 40-50 sec for
this routine to time out... that's why I'm using a ping first to verify that
my DNS will find something willing to respond before I spend any more
resorces on checking host name.
Kjell
"Irfan S. Fazli" wrote:
Thanks Kjell and KP..
Since ours is a closed (no Internet) WAN, I believe the IP address can be
trusted.
We can check for SystemName via WMI hostname check for additional security.
Please forward some code /link.
thanks,
--
IRFAN.
"Kjell" wrote:
Can you consider using PING and WMI host check ?
Ping has the advantage it's fast, but it can be fooled, any machine having
the IP address forwarded by a DNS will respond.
WMI host check is correct but slow, especially if the machine is down.
So, i'm using a combination, if PING answers I will do a WMI host name check
to verify responding host name is the one I asked for.
If your machine has a fixed IP I guess you could trust it just using Ping..
I can provide you with some code snipets if you like...
WMI requires domain rights, I'm not sure if it requires domain admin rights
or if it can be a bit below that, I'm runnig my stuff as a domain admin.
Kjell
"Irfan S. Fazli" wrote:
I have my application (vb6) that runs on a LAN at branch offices.
On the server m/c of branch a Virtual PC (Win-2003 R2 starts automatically)
runs in the background that communicates with our HQ office via a WAN.
The application transfers data to Virtual PC.
Although not allowed, but the Virtual PC can be shut down by the branch.
Query: I want the desktop application to determine if the Virtual PC is
running or not.
Thanks,
--
IRFAN.
- Follow-Ups:
- RE: Determine if Virtual PC is running
- From: Irfan S. Fazli
- RE: Determine if Virtual PC is running
- Prev by Date: Re: Newbie to VB: to what degree is VB event driven
- Next by Date: Vista Support
- Previous by thread: Re: Determine if Virtual PC is running
- Next by thread: RE: Determine if Virtual PC is running
- Index(es):
Relevant Pages
|