Re: Killing a process
- From: "Dan Freeman" <spam@xxxxxxxxxxxxx>
- Date: Thu, 26 Oct 2006 09:19:42 -0700
Doesn't surprise me a bit. In fact I would have been surprised if there
wasn't SOME sort of failure with limited users. Everything goes wacky in
terminal services with restricted users.
People who run in terminal services often do so specifically to tightly
control user rights on the box, and usually get exactly what they wanted.
Unfortunately, that means our software often can't perform the tasks they've
asked us to perform -- even those that work perfectly well on stand-alone
windows.
It's the way things are with terminal services. You need to reach some sort
of agreements with your clients that you're not going to be able to perform
the tasks that they've restricted at the user level. <shrug>
Dan
Mark Burgum wrote:
I found some code on here a while ago ( i can't remember who posted
it), which allowed you to kill a named process on a computer. As i
was creating a new part of our package that lived in a seperate
executable at that time, i decided to incorporate it. i recently
found that the code had a slight flaw when used in a terminal server
environment, where it will kill everyones process, not just the
process for the user who was running it. So i did some research and
came up with the following.
PROCEDURE kill_it
LPARAMETERS what_to_kill
LOCAL user,domain,m.lcsystemstring
oWMI = GETOBJECT('winmgmts:{impersonationLevel=impersonate}')
cQuery = "select * from win32_process where name='"
+ALLTRIM(what_to_kill) +"'"
oResult = oWMI.ExecQuery(cQuery)
FOR EACH oProcess IN oResult
m.user = ""
m.domain = ""
If oProcess.GetOwner ( @User, @Domain ) = 0
m.lcsystemstring = SYS(0)
IF TYPE('m.user') = 'C' AND ALLTRIM(SUBSTR(m.lcsystemstring,AT('
#',m.lcsystemstring))) = ALLTRIM(m.user)
oProcess.Terminate(0)
ENDIF
endif
NEXT
endproc
which sounded fine, and works a treat on my local machine. however
under terminal server i get an error for some users.
ERROR: (1440) OLE exception error: Exception code c0000005. OLE
object may be corrupt
The error occurs when trying to make the getOwner call, which
occording to the documentation should return a number other than 0 if
it fails. instead it occasionally errors. This behavoiur would appear
to be a security issue, as so far it only happens to people with user
rights on the terminal server environment. So in order to get over
this, i will now have to trap this error, which should never have
happened in the first place! unless someone knows a work around or
another way of achieving this?
anyway i hope this saves someone else some heartache.
Mark Burgum
.
- References:
- Killing a process
- From: Mark Burgum
- Killing a process
- Prev by Date: Re: Finding Name of Executable
- Next by Date: Re: Access a vb.net DLL from VFP 8.0
- Previous by thread: Killing a process
- Next by thread: Re: Killing a process
- Index(es):
Relevant Pages
|