Re: Killing a process



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


.



Relevant Pages

  • Re: Test Your Political Position
    ... No big surprise there. ... Best described as a Democrat. ... I also feel that ANYONE on welfare needs to do some sort of work to earn their keep. ... Nobody deserves a totally free ride. ...
    (rec.food.cooking)
  • Re: Yes, read Pullman
    ... I said nothing of the sort boastfully or otherwise, ... "It makes me unhappy to see other people in pain, and if I am the cause ... surprise, actually. ...
    (alt.fan.harry-potter)
  • Re: Internet Browsing in a TS session
    ... utilities that help with this sort of thing. ... > We have a client that is complaining about Internet browsing through a ... > Remote session. ... A user connects to the Terminal server using Remote Desktop ...
    (microsoft.public.windows.terminal_services)
  • Re: New KH Hub, defective??
    ... kington99 wrote: ... Youu gotta love this sort of surprise cause you are usually left ...
    (rec.sport.unicycling)
  • Re: "Send" causes re-boot...?
    ... > Running OL2K I just had a rather odd experience: ... > Instantly, the screen went black, and, to my surprise, I realized a ... > I assumed that we had some sort of power spike that caused that to ... I have a very good backup system and quickly reverted to ...
    (microsoft.public.outlook)