Page 1 of 1 1
Topic Options
#145716 - 2005-08-16 08:42 PM Detecting a running application
jnkmail001 Offline
Lurker

Registered: 2005-07-06
Posts: 2
I am using a simple KiX script to run xpsp2 in quiet mode so I can use the messagebox function to let users know that it is running. I do not want to force the reboot, so I using /noreboot but I need to prompt for a reboot once finished. Is there a command to check that xpsp2.exe is still resident? I figure once it's complete I could then prompt for the reboot.

Mike

Top
#145717 - 2005-08-16 09:01 PM Re: Detecting a running application
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
This would do it. Just change the name of the process (in this case I used outlook for testing) to the name of the XPSP2 setup process.
The actual UDF posting can be found here http://www.kixtart.org/ubbthreads/showfl...=true#Post82991

Code:

Break on


$pid= EnumProcess("OUTLOOK.EXE")
While $pid <> ""
$pid= EnumProcess("OUTLOOK.EXE")
Sleep 5
Loop

Function EnumProcess($exe, optional $terminate, optional $Computer)
Dim $winmgmts, $ExecQuery, $Process, $id
If NOT $computer
$computer=@wksta
EndIf
$winmgmts="winmgmts:{impersonationLevel=impersonate}!//$COMPUTER"
Select
Case Val($exe)>0
$ExecQuery="select * from Win32_Process where ProcessId='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For Each $Process in $GetObject
If $terminate
$=$Process.Terminate
EndIf
$EnumProcess = $Process.name
Next
$GetObject=''
Case VarType($exe)=8
$ExecQuery="select * from Win32_Process where Name='$exe'"
$GetObject=GetObject($winmgmts).ExecQuery($ExecQuery)
For Each $Process in $GetObject
If $terminate
$=$Process.Terminate
EndIf
$id=$Process.ProcessId
$EnumProcess = "$Id" + "|" + "$EnumProcess"
Next
$EnumProcess=Left($EnumProcess,Len($EnumProcess)-1)
$GetObject=''
Case 1
Exit 1
EndSelect
EndFunction

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#145718 - 2005-08-16 09:01 PM Re: Detecting a running application
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Oh... and btw welcome to this board.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#145719 - 2005-08-16 09:01 PM Re: Detecting a running application
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
a quick search of the UDF's turns up some links that may be of some use.

Process

looks like EnumProcess() is what you are looking for.

Top
#145720 - 2005-08-16 09:03 PM Re: Detecting a running application
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Nice one Mart!
Top
#145721 - 2005-08-16 09:03 PM Re: Detecting a running application
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
WOW three posts with the same time stamp
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#145722 - 2005-08-16 09:03 PM Re: Detecting a running application
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I am just stalking you...
Top
#145723 - 2005-08-16 09:06 PM Re: Detecting a running application
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Someone call the cops.....I got a stalker
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#145724 - 2005-08-16 09:16 PM Re: Detecting a running application
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Mart,

Think we have to call you Lonk the second...

You are very busy lately

Way to go!!!!
_________________________
Co


Top
#145725 - 2005-08-16 09:23 PM Re: Detecting a running application
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Yeah well a few weeks ago I lost my job so got like 10 hours of free time extra each day. Will be starting a new job next Monday.

Don't know about calling me the next lonk though I'm nowhere near lonks postcount.

Anyway this is going off topic so lets see what jnkmail001 can do with the enumproc() and wait how far he/she gets.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#145726 - 2005-08-16 09:45 PM Re: Detecting a running application
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
The actual process you're looking for would probably be UPDATE.EXE
Top
#145727 - 2005-08-16 10:02 PM Re: Detecting a running application
jnkmail001 Offline
Lurker

Registered: 2005-07-06
Posts: 2
Thanks for the quick replies guys. I've tracked the processes and xpsp2 is running the whole time and does end at completion, it may parallel update.exe I didn't check that.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 781 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.063 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org