Notices
Non Scooby Related Anything Non-Scooby related

Killing a process on NT without knowing hwnd in VB6

Thread Tools
 
Search this Thread
 
Old 20 December 2001, 06:17 PM
  #1  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

Anybody got any ideas how I can kill/terminate a process from within a vb app... I know what the exe is called... just dont know the PID or HWND... as far as I can work out I may need to use PSAPI.DLL...

Or anybody have any ideas how to work out the pid for the app and then kill it??

David
Old 20 December 2001, 09:28 PM
  #2  
mutant_matt
Scooby Regular
 
mutant_matt's Avatar
 
Join Date: Sep 2000
Location: London
Posts: 7,039
Likes: 0
Received 0 Likes on 0 Posts
Talking

David, I know it's a bit of a bodge but if you run the KILL.EXE that comes with the Resource Kit, you can do call the EXE from VB thus:

KILL <EXE_Name>

You don't need to figure the Process ID with this exe (unlike the Unix version of KILL).

Matt
Old 21 December 2001, 01:05 AM
  #3  
KF
Scooby Regular
 
KF's Avatar
 
Join Date: Feb 2000
Posts: 405
Likes: 0
Received 0 Likes on 0 Posts
Post

You can walk the windows Z-order and check the window type / name for a match.
Really it's a horrible thing to do, and there is a reason it is so difficult Is it a well known app that you are trying to kill?
KF.
Old 23 December 2001, 10:42 PM
  #4  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

I have written an app to display our computer usage policy and if you dont agree then it logs you off, but I also want to kill the login script which we process using kixtart Kix32.exe (from resource kit...)

David
Old 23 December 2001, 10:43 PM
  #5  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

ps... looks like it maybe kill.exe yet...!!!!

David
Old 24 December 2001, 01:26 AM
  #6  
KF
Scooby Regular
 
KF's Avatar
 
Join Date: Feb 2000
Posts: 405
Likes: 0
Received 0 Likes on 0 Posts
Post

Surely the best way of doing this is rewriting the script?
KF.
EDIT: In fact I am going to be more emphatic. Try the editing script approach first before going around killing processes (yuk).

[Edited by KF - 12/24/2001 1:28:29 AM]
Old 24 December 2001, 01:34 AM
  #7  
KF
Scooby Regular
 
KF's Avatar
 
Join Date: Feb 2000
Posts: 405
Likes: 0
Received 0 Likes on 0 Posts
Post

Another thing. How is the Use policy application started?

If you are using shell command in the script, the docs state that you are going to be stopping script execution until program exits.
So, you are going to killing the paused, owning process that is controlling the context of the application that is going to kill it. Sucks teeth...

Modify the script. If you want some pointers, just ask.
KF.
Old 24 December 2001, 10:09 AM
  #8  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

I know that its not the best way of doing it but... I am assuming that no one is going to disagree!... The exe actually calls the logoff sequence... which in turn will kill the process...

The best way would be use return codes and check for these in the script and then exit... Dont suppose you know how to do that in VB do you??

Cheers

David
Old 24 December 2001, 10:19 AM
  #9  
KF
Scooby Regular
 
KF's Avatar
 
Join Date: Feb 2000
Posts: 405
Likes: 0
Received 0 Likes on 0 Posts
Post

What I would do is write something to the registry. Start your VB app and use it (the VB app) to write to the registry if the person agrees to the policy. If you use Shell to start the app, just check the key when the script regain control, or use the Run command to launch your app, and set up a loop with a sleep command in it, which polls that registry setting for a change.

Either that or display your usage text using the MessageBox function, and check the return from it.
KF.
Old 24 December 2001, 11:37 AM
  #10  
David_Wallis
Scooby Regular
Thread Starter
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

I was going to display the message using msgbox.. but the policy is like war and peace... so I am using an rtf control... so that hr can change it as they want.. Think you are probably right... will write a reg key under winlogon...

Cheers

David
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
SilverM3
ScoobyNet General
8
24 February 2021 01:03 PM
kenc
Wanted
6
02 October 2015 09:12 PM
GB270_CALUM
General Technical
4
01 October 2015 09:50 PM
Sub-Subaru
General Technical
1
28 September 2015 12:47 PM



Quick Reply: Killing a process on NT without knowing hwnd in VB6



All times are GMT +1. The time now is 09:23 AM.