#140999 - 2005-06-06 12:08 AM
Trying to use the EndProc() UDF
chewbaccabenz
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
#141001 - 2005-06-06 01:32 AM
Re: Trying to use the EndProc() UDF
chewbaccabenz
Fresh Scripter
Registered: 2005-06-03
Posts: 6
Loc: Waco, TX USA
Any Ideas?
_________________________
Help Computa!
Top
#141003 - 2005-06-06 02:22 AM
Re: Trying to use the EndProc() UDF
NTDOC
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
#141005 - 2005-06-06 02:49 AM
Re: Trying to use the EndProc() UDF
chewbaccabenz
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
Moderator: Glenn Barnas , NTDOC , Arend_ , Jochen , Radimus , Allen , ShaneEP , Ruud van Velsen , Mart
0 registered
and 292 anonymous users online.