I need to check if an application is running on a remote computer. This application is running in a command window (process.name = cmd.exe). There are more than one cmd.exe running so only the application name is the key!
You can usually get the command line that was executed to create the cmd.exe process through WMI.
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
This is a very generic example but it should point you in the right direction:
Option Explicit
WScript.Echo ListAllProps(".", "WIN32_Process")
Function ListAllProps(strComputer, strClass)
Dim oWMISvc
Dim colInstances
Dim oInstance
Dim oProp
Dim strVal
Dim strReturn
Set oWMISvc = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colInstances = oWMISvc.ExecQuery("Select * from " & strClass,,48)
For Each oInstance in colInstances
For Each oProp In oInstance.Properties_
If IsNull(oProp.Value) Then
strVal = "NULL"
Elseif oProp.IsArray Then
strVal = "ARRAY: " & Join(oProp.Value, ";")
Else
strVal = oProp.Value
End If
strReturn = strReturn & oProp.Name & ": " & strVal & VbCrLf
Next
strReturn = strReturn & "**************************************" & VbCrLf & VbCrLf
Next
ListAllProps = strReturn
End Function
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
...don't kick me out of this thread - maybe it's just the quality of my description:
open two 'command-windows' and give them different names (e.g. title window1 and title window2)
If you have a look at the task manager the 'application panel' shows the two applications 'window1' and 'window2' - on the 'process-panel' there are just two processes named 'cmd.exe'
these two applications do NOT run locally, the are running on a server. My job is to get a notification if application 'window1' is not running!
on my local machine this is very easy done by
-------------------------------------------
Set WshShell = CreateObject("WScript.Shell")
WshShell.AppActivate "notepad"
-------------------------------------------
hi, if you want to look into what has happened (i.e. you have let control go) then TTKP has provided you with the place to start you look.
the Win32_Process class properties will lead you down an investigation path.
have you run TTKP's code? do any of the properties give you what you want? i dont think you have answered this...
will .Description, .ExecuteablePath not help? or you might find you have to look further...i.e. a Win32_Process class property will reference another WMI Class which will hold the info you want,,,see the thread about the use of USB class and PnP classes for USB printer manips...
if you have not let go of the control then you will be able to attack it differently. if your script starts the actual threads then will be able to get a .ProcessID if you start the thread with Win32_Proccess.Create for instance(or such like, this will be unique and not rely on a text reference to window names etc' number which you can reference and check against
I tried all of your hints (some of them before you all gave them) - I'm 'going round in circles' at the moment.
I can't find the missing link between the 'appactivate' which is availlable within this shell and doing the things i need (but only on my local machine) and the processes i can see on a remote machine. See my example (dated: 17 Feb 06 5:26) which shows the problem.
@mrmovie: my script is not starting this process (but maybe it is an idea to start this process with a defined process.id - how can i do this?)
[1] If the process is on the remote, what would appactivate enter the picture? It would be useless.
[2] As noted, you can even get command line from the properties exposed through win32_process for finer distinction among processes with command prompt. After you make the identification, closing the application is done by the method of the process instance itself. But the command line property is avail only for winxp up (not even avail to win2k).
How do you check if an application is running on a remote machine? This application is a service running in a command window. I can see that four 'cmd.exe' are running on this remote machine, but which one belongs to the application I need to keep running?
How do you check if an application is running on a remote machine? This application is a service running in a command window. I can see that four 'cmd.exe' are running on this remote machine, but which one belongs to the application I need to keep running?
Or - how can I assign a process id to a process on starting the process? If this is possible I would know the process id I have to check for!
you say you can see 4 cmd.exe processes running on the machine...as described by users posts....check the .CommandLine property of each cmd.exe process....
i think the solution has already been given to you
What kind of control do you have over the service? You can copy CMD.EXE somewhere and rename it to MYAPP.EXE. It is then easily identifiable. We do this for wscript.exe when we have multiple scripts running at once on the same box so we can tell them apart.
@Jerz:
technically this would be possible - but all machines are qualified and this would be a change within the operating system which is not allowed.
@jessicatechy:
this works but I don't want to close alle cmd-processes, I need to check if a special process is running (sorry the header of the thread does not exactly describe my problem).
What I need is the link between application and process in a remote session from a WinXP-Client to a Win2000-Server...
Then it sounds like you need to paint a wall red but all you have is blue paint.
[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.