Notices
Non Scooby Related Anything Non-Scooby related

Killing a process on NT without knowing hwnd in VB6

Thread Tools
 
Search this Thread
 
Old Dec 20, 2001 | 06:17 PM
  #1  
David_Wallis's Avatar
David_Wallis
Thread Starter
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
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
Reply
Old Dec 20, 2001 | 09:28 PM
  #2  
mutant_matt's Avatar
mutant_matt
Scooby Regular
 
Joined: Sep 2000
Posts: 7,039
Likes: 0
From: London
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
Reply
Old Dec 21, 2001 | 01:05 AM
  #3  
KF's Avatar
KF
Scooby Regular
 
Joined: Feb 2000
Posts: 405
Likes: 0
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.
Reply
Old Dec 23, 2001 | 10:42 PM
  #4  
David_Wallis's Avatar
David_Wallis
Thread Starter
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
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
Reply
Old Dec 23, 2001 | 10:43 PM
  #5  
David_Wallis's Avatar
David_Wallis
Thread Starter
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Post

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

David
Reply
Old Dec 24, 2001 | 01:26 AM
  #6  
KF's Avatar
KF
Scooby Regular
 
Joined: Feb 2000
Posts: 405
Likes: 0
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]
Reply
Old Dec 24, 2001 | 01:34 AM
  #7  
KF's Avatar
KF
Scooby Regular
 
Joined: Feb 2000
Posts: 405
Likes: 0
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.
Reply
Old Dec 24, 2001 | 10:09 AM
  #8  
David_Wallis's Avatar
David_Wallis
Thread Starter
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
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
Reply
Old Dec 24, 2001 | 10:19 AM
  #9  
KF's Avatar
KF
Scooby Regular
 
Joined: Feb 2000
Posts: 405
Likes: 0
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.
Reply
Old Dec 24, 2001 | 11:37 AM
  #10  
David_Wallis's Avatar
David_Wallis
Thread Starter
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
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
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
SilverM3
ScoobyNet General
8
Feb 24, 2021 01:03 PM
kenc
Wanted
6
Oct 2, 2015 09:12 PM
GB270_CALUM
General Technical
4
Oct 1, 2015 09:50 PM
Sub-Subaru
General Technical
1
Sep 28, 2015 12:47 PM




All times are GMT +1. The time now is 04:23 PM.