Page 1 of 1 1
Topic Options
#140999 - 2005-06-06 12:08 AM Trying to use the EndProc() UDF
chewbaccabenz Offline
Fresh Scripter

Registered: 2005-06-03
Posts: 6
Loc: Waco, TX USA
Hello,

I am trying to use the EndProc() UDF to close all instances of KIX32.EXE on the local workstation when a button is clicked, but for some reason they will not close. If I change the $PROC to "notepad.exe" it will close notepad. What am I doing wrong? I am running the button in a wkix32.exe kixform script. The code is below:

Code:

;************* Button2 **************
$Button2 = $Form.Controls.Button()
$Button2.FontBold = "True"
$Button2.FontSize = 12
$Button2.Height = 39
$Button2.Left = 200
$Button2.Text = "Stop Printing"
$Button2.Top = 380
$Button2.Width = 254
$Button2.OnClick = "OnButtonClick2()"
;**************************************

Function OnButtonClick2

$COMPUTER = @WKSTA
$PROC = "kix32.exe"
ENDPROC($PROC,$COMPUTER)


EndFunction

FUNCTION ENDPROC($PROC, optional $COMPUTER)
Dim $Process,$RC
IF $COMPUTER=''
$COMPUTER='.'
ENDIF
For each $Process in GetObject('winmgmts:{impersonationLevel=impersonate}!\\'+$COMPUTER+'\root\cimv2')
.ExecQuery('select * from Win32_Process where Name='+'"'+$PROC+'"')
$RC=$Process.Terminate
Next
ENDFUNCTION



Thanks for all your help,

-Michael
_________________________
Help Computa!

Top
#141000 - 2005-06-06 12:42 AM Re: Trying to use the EndProc() UDF
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Ruud put kill resist into KiX so I think you will have to use more agressive tools to kill it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141001 - 2005-06-06 01:32 AM Re: Trying to use the EndProc() UDF
chewbaccabenz Offline
Fresh Scripter

Registered: 2005-06-03
Posts: 6
Loc: Waco, TX USA
Any Ideas?
_________________________
Help Computa!

Top
#141002 - 2005-06-06 01:56 AM Re: Trying to use the EndProc() UDF
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
if you are using any other os than XP, then kill.exe is for you.
otherwise, destroy the kix32.exe and use wkix32.exe everywhere.

wkix32.exe does not have such protection but it can easily be shutdown in most cases.
_________________________
!

download KiXnet

Top
#141003 - 2005-06-06 02:22 AM Re: Trying to use the EndProc() UDF
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: Space
Don't know, this code worked fine for me. Killed KIX32.EXE v4.5 RC1 no problem when using WKIX32.EXE to launch it.

Break On
Dim $SO,$Pause
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('WrapAtEOL','On')


Dim $Kill
$Kill=EndProc('KIX32.EXE',@WKSTA)
? 'Killing of KIX32.EXE ' + @ERROR
? Get $Pause ?


Function EndProc($Proc, optional $Computer)
Dim $Process,$RC
IF Not $Computer $Computer='.' EndIf
For each $Process In GetObject('winmgmts:{impersonationLevel=impersonate,(debug)}\\'
+$COMPUTER+'\root\cimv2').ExecQuery('select * from Win32_Process where Name='+'"'+$PROC+'"')
$RC=$Process.Terminate
Next
EndFunction




 

Top
#141004 - 2005-06-06 02:33 AM Re: Trying to use the EndProc() UDF
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Ja, well... that is more aggressive, isn't it?
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#141005 - 2005-06-06 02:49 AM Re: Trying to use the EndProc() UDF
chewbaccabenz Offline
Fresh Scripter

Registered: 2005-06-03
Posts: 6
Loc: Waco, TX USA
Thanks NTDOC, your function worked. It looks a little different from the one I had.

-Michael
_________________________
Help Computa!

Top
#141006 - 2005-06-06 01:48 PM Re: Trying to use the EndProc() UDF
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well...
only difference I see is the debug mode in the latter.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 292 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.944 seconds in which 0.908 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org