RE: Determine if Virtual PC is running



I have got VBnet code as suggested.
When trying to include call to your function DoMyAdvancedPing(hostname /ip)
in the VBnet code just before Cleanup I am getting error no. 642 - "The
remote server machine does not exist or is unavailable"
The same is the result when I call this function independently.
What does the line of getobject(....) indicate. Please explain.
Thanks,
--
IRFAN.



"Kjell" wrote:

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.

.



Relevant Pages

  • RE: Determine if Virtual PC is running
    ... I've just checked my source code and my code for PING actually derives from ... when pinging a local pc by host name, ... that IP-address will probably respond. ... We can check for SystemName via WMI hostname check for additional security. ...
    (microsoft.public.vb.general.discussion)
  • Re: connecting via broadband?
    ... > Ping statistics for 193.252.22.137: ... >> mail server and that it is responsive so you get a mail session ... >> host that responds to 'ping' does NOT mean the server program is ... >> actually running or responsive on that host. ...
    (microsoft.public.outlook.general)
  • Re: host availability
    ... >>>google.com, my default gateway, comcast's mail server etc. ... a host was "up or down". ... If you don't get an answer to a ping request, ... happened to reset the interface right then, remote system got trojaned ...
    (comp.security.firewalls)
  • RE: ICMP (Ping)
    ... I do like your reasoning that others do not generally have a business need ... to ping your hosts, however I still prefer to allow this service not simply ... how many hosts do not respond to ICMP echo. ... DHCP server should be able to assume that if the IP were in use a host would ...
    (Security-Basics)
  • Re: How to resolve names
    ... So I can ping and try to ssh/telnet the 2 other machines from my PC via ... I cannot do it by using their host names although I get proper ... # entry should stop if the search in the previous entry turned ... # passwd: files nis ...
    (comp.os.linux.networking)