Here is the easy way to monitor if the application is open and the number of instances open:
code:
Function AppInstances($appname)
$countproc = 0
For Each $process in GetObject("Winmgmts:").ExecQuery("Select Name FROM Win32_Process Where Name = '" + $appname + "'")
$countproc = $countproc + 1
Next
$AppInstances = $countproc
EndFunction
Call the function:
code:
$app = "Calc.exe"
$app + " has " + AppInstances($app) + " active process(es)." ?
This could possibly be useful if using task scheduler via logon script and wanting to wait for a task to complete before continuing...
Brian
P.S....
After thinking about it, I believe with a client and serverside script, it would be able to create a UDF called
RunAsAdministrator($commandline)
1. Client script passes the $commandline to server script.
2. Server script generates a scheduled task on the PC from the $commandline sent.
3. Client waits until program complete before continuing.
[ 17 May 2002, 22:31: Message edited by: BrianTX ]