Re: View running processes of remote machine
- From: "Randy Birch" <rgb_removethis@xxxxxxxx>
- Date: Wed, 27 Jul 2005 23:36:54 -0400
Let's see if I can explain this properly. When a PC joins a domain, and then
is shut down, the domain controller(s) does not necessarily know the machine
has gone offline. So when an enumeration takes place the machine is listed -
it is after all a member of the domain - but as you've discovered it's not
until you try and access it that you find it's off (or offline). And I don't
recall there being any magic solution to this, as it's a common network
admin issue not confined to VB programming.
I think, rather than try to blindly attempt to enumerate the process on a
box, you might be further off time-wise if you first took a sec to try and
ping the box. The code here should get you started on that -
http://www.vbnet.mvps.org/code/internet/pingbyhostname.htm. Just pass the
machine name rather than a URL as the demo shows. Depending on your setup it
may require the domain\machine name or just the machine name alone. On a
workgroup it only needs the machine name (no slashes). You should be able
on a local network to get away with setting the PING_TIMEOUT value to much
less than 500 ms - probably around 100-200 would do. If you get at True
returned, then call your WMI routine. If false, move on to the next machine.
If the machines are all on the same network, I believe that the
SocketsInitialize routine only needs to be called on first starting the
demo, and correspondingly the SocketsCleanup routine on ending, rather than
for each call to the ping routine (see the Command1_Click code). But these
are very fast routines, so the overhead of repeated calling is probably not
significant in the long run - never had an opportunity to test the
differences.
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------
"Capp" <Capp@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5AEFF330-27E8-4E0E-BDC4-F8300C183EE9@xxxxxxxxxxxxxxxx
:I have a small problem. This is what I'm running:
:
:
: visual basic
:
code:---------------------------------------------------------------------------
:
: Function IsProcessRunning(strServer, strProcess)
: Dim Process, strObject
: IsProcessRunning = False
: strObject = "winmgmts://" & strServer
: For Each Process In GetObject(strObject).InstancesOf("win32_process")
: If UCase(Process.Name) = UCase(strProcess) Then
: IsProcessRunning = True
: Exit Function
: End If
: Next
: End Function
:
:
: Public Sub CheckRunning()
: On Error GoTo errhand
: Dim strComputer, strProcess
: strComputer = lstComputers.Text
: strProcess = "notepad.exe"
: If (IsProcessRunning(strComputer, strProcess) = True) Then
: lstPrograms.AddItem "Notepad" & " " & "is running"
: Else
: lstPrograms.AddItem "Notepad" & " " & "is Not running"
: End If
: --------------------------------------------------------------------------------
:
: This works almost all the time, but I run into an error occassionally. The
: script I run lists all the pc' on my network (like I want it to). But, it
: also lists the pc even if it is turned off. The problem I am running into
is
: 1) It errors out if it can't connect to the machine, and 2) if It is a
: machine on a different subnet (WAN), I don't have access to the machine
and
: it errors out.
:
: It's not giving me a normal error though. It is giving me the error:
: Title -> Component Request Pending
: Text -> This application cannot be completed because the other application
: is busy. Choose 'Switch To' to activate the busy application and correct
the
: problem.
: Options -> Switch To..., Retry
:
: No matter what I try, it keeps coming up. I end up having to kill it
through
: the task manager.
:
: How can I fix this so that if it can't check the computer, it will stop
: trying and go back to idle without erroring?
:
: I tried doing the "On error..." method, but it still craps out on me.
:
: Thanks in advance for the help
:
.
- Follow-Ups:
- Re: View running processes of remote machine
- From: Capp
- Re: View running processes of remote machine
- References:
- View running processes of remote machine
- From: Capp
- View running processes of remote machine
- Prev by Date: Re: Calculate age from now
- Next by Date: Re: Calculate age from now
- Previous by thread: View running processes of remote machine
- Next by thread: Re: View running processes of remote machine
- Index(es):
Relevant Pages
|