Archived Boards > WinBatch Script Exchange

Script to detect running process

(1/2) > >>

paljets:
So I need to write a script that does the following:

Check every 60 seconds to see if a process under the user's user-id is running.  If it is NOT running, issue a ts disconnect

the script needs to check every 60 seconds till the process is no longer found, then issue the disconnect..

Anyone help?

DAG_P6:
The Process Extender probably has everything you need to do so.

td:
Here is a link to an example that uses the Process Extender and WMI to obtain the user name associated with a process.

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/Process~ID+Get~Username~from~a~Process.txt

The Terminal Service extender's wtsDisonnectSession function can be used to disconnect a session.

ChuckC:
Also of interest... Take a look at the sample script for the Terminal Services extender, as it shows how to use the extender to enumerate all of the processes running within a specified [e.g. the current] TS session.   For purposes of simply determining if a process is running, it will pull double duty and nix out the need for using the Process Extender.  Since it is the session within which the process runs, and not the actual username under which the process runs, which is important, the TS extender can provide all the required information w/o having to resort to using a combination of the Process extender and WMI.



--- Quote from: td on February 13, 2015, 06:44:12 am ---Here is a link to an example that uses the Process Extender and WMI to obtain the user name associated with a process.

http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WIL~Extenders/Process~ID+Get~Username~from~a~Process.txt

The Terminal Service extender's wtsDisonnectSession function can be used to disconnect a session.

--- End quote ---

td:
It would appear that whether or not the user id is important is contingent on several factors that OP did not specify.

Navigation

[0] Message Index

[#] Next page

Go to full version