Re: Terminating processes owned by other users on a Terminal Serve



Alex,

Thank you, that worked. I am still curious how I could do this without
resorting to a command line.

--Aaron

"Alex K. Angelopoulos" wrote:

Aaron,

I'm not certain why this happens - I don't recall trying to test this on a
TS in the past - but I think it may be due to some selective
compartmentalization done by the server to prevent ugly applications from
inadvertently doing such a global shutdown.

The simplest workaround, which should work fine, is to use the commandline
tskill utility instead. After your wait for them to respond, instead of
querying WMI again, simply use your WScript.Shell instance to perform a
global kill with the /A parameter, like this:

result = objShell.Run("tskill msaccess /A", 0, 1)

Important bits here:

+ result will contain the exit code from running tskill, but I'm not certain
it gives you anything useful; it's always been 1 for me.

+ Note that you use the BASE name of the application, akin to UNIX kill
commands - DO NOT use the .exe extension, because tskill implicitly adds it.
It won't find msaccess.exe

+ The /A parameter forces the app to die in all sessions.

+ the 0 parameter tells the script to spawn tskill in a hidden window; you
can change this to 1, 3, or 6 to display/maximize/minimize the window. It's
probably not important for you, I'm simply including it because I need to
for the 3rd parameter.

+ The 3rd parameter, with value 1 , tells the script to wait until tskill
finishes before returning. This ensures that the msaccess instances have
been already killed before you do anything else.
.