0

I have 2 VB6 application which may launch the same VB.NET application (same exe) via a subMenu. The VB6 code to start this application is a Shell command :

ret = Shell(exe, 1)

My problem is when the user exit the main application (VB6), it won't close the VB.NET application if he opened it.

I tried to use the Taskkill command. It effectively kills the application, but it kills this app for every users on the server !!

I need to do it only for the current user. Can anyone help ?

EDIT : I found some documentation with Taskkill. It seems that i can precise a user and a domain in the command. I use the following code :

Dim cmdShell As String
quote = Chr$(34)
cmdShell = "taskkill.exe /f /fi " & quote & "USERNAME eq " & _
       LCase(connection_User) & quote & " /im " & exeToKill

If someone have a better idea, i'm in :)

nbadaud
  • 694
  • 7
  • 26
  • This might help: http://stackoverflow.com/questions/5685972/how-to-wait-for-a-shell-process-to-finish-before-executing-further-code-in-vb6 – Derek Jul 19 '16 at 10:51
  • 2
    First address the much bigger problem, it invariably also misbehaves badly when the vb.net app dies on an unhandled exception. You can't tell and you don't know why. Once you have that, stopping it becomes trivial. The only really correct way to do this is to create a class library instead. Easy to do with the [ComVisible] attribute. – Hans Passant Jul 19 '16 at 12:55

0 Answers0