Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Monitoring Subprocesses 2

Status
Not open for further replies.

steinshouerj

IS-IT--Management
May 22, 2003
29
US
I am trying to find a way to monitor a subprocess. Using the following wmi code I can get a list of all running processes.

Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process")

Any running subprocess are not listed. Is there a way of seeing if a subprocess is running?
 
Please disregard my question. I was able to solve my problem by using using win32_thread to count the number of threads for a process.
 
arent you going to share your solution so other can learn/benefit from them?
 
Using the following WMI script, I was wanted to loop until the setup.exe process had ended. The probroblem is that setup.exe is a 16bit application that run under NTVDM.exe. This is a 16bit emulation program for Windows. The WMI query did not see a Setup.exe process.

intProcess = 1
Do While intProcess <> 0
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'Setup.exe'")
intProcess = colProcesses.Count
Loop

After making my first post. I found that the WMI class Win32_Process has a property called ThreadCount. I am able to use this to to see if setup is finished running. If NTVDM.exe has more than 2 threads then the setup program is running. I included the code I used below.

IntThreads = 0
Do While IntThreads <> 2
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'NTVDM.exe'")
For Each objItem in colItems
IntThreads = objItem.ThreadCount
WScript.Sleep 1000
Next
Loop

 
a good post and one that i am sure people will find useful when monitoring/deploying patches/applications.
 
i would say it was worth a star.
i would advise caution on your do loop statement.

this means the script will stay in an endless loop UNTIL IntThreads = 2

intThreads is nested in a For Each loop. could you get the case where IntThreads NEVER = 2? I would say it is mathematically possible


 
absolute gold my friend, a star for you.
this puts me many steps further towards solving, my current problem, reffered to in my post about IO::Socket for System Administration of windows 2003 server
thread219-780353, please take a look at this thread and tell me what you think, my best plan of attack would be.
besides (not) using sockets... [afro]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top