Results 1 to 14 of 14

Thread: Killing .exe's

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Killing .exe's

    Hello friends, let's say from my program, A, I want to kill another program, B. Does the kill function from A work if B is running?
    Also if not then is there any way in which I can unload/exit B from my program A and kill it? Thanks for all the help!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Killing .exe's

    By kill it you simply mean stopping it from running right?

    Or, are you asking how to delete it altogether?

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Killing .exe's

    Why do you need one program to "killl" the other?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: Killing .exe's

    I want to stop the other program from running and delete it. Is it possible?

  5. #5
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Killing .exe's

    What is this other program?

    Does it belong to you?

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: Killing .exe's

    Yes it does belong to me.

  7. #7
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Killing .exe's

    Does it have a static window caption?

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2007
    Posts
    95

    Re: Killing .exe's

    What is a static window caption? Do you mean is it shown on the window task bar?

    If so, yes it's shown in the windows task manager and the task bar.

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Killing .exe's

    I'm referring to the text in its own caption bar, at the top of the form.

    And, by static, I mean does it remain constant, or does it, under certain, circumstances, change?

    I ask these questions because to close it, you can use the FindWindow API which would require its caption. That would give you the window handle.

    Once you had the Window handle, you can pass it a shutdown message.

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Killing .exe's

    Here is an example:
    vb Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    2. (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    3.  
    4. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
    5. (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
    6. ByVal lParam As Long) As Long
    7.  
    8. Private Const WM_CLOSE = &H10
    9.  
    10. Private Sub cmdCloseApp_Click()
    11. Dim lngCloseIt As Long
    12. lngCloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
    13. PostMessage lngCloseIt, WM_CLOSE, CLng(0), CLng(0)
    14. End Sub

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Killing .exe's

    You should also check if its a parent window because if its not then it wont close the app.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Member
    Join Date
    May 2006
    Location
    UK
    Posts
    54

    Re: Killing .exe's

    Is it possible to kill a process without using the window caption, or would I have to use an API to discover all the open apps, and select the one to kill. This would be useful for me, so that I can close firefox, but have all the tabs still there when I re-open it.

  13. #13
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Killing .exe's

    Yes, you can do it by the process name instead. Search the forums for Terminate Process.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  14. #14
    Lively Member Moneybucks's Avatar
    Join Date
    Apr 2006
    Location
    Kingston Upon Thames -UK
    Posts
    123

    Re: Killing .exe's

    See this post, it contains some information on TerminateProcess API:

    http://www.vbforums.com/showthread.php?t=464389
    If, somehow, I help you, please rate the post using the scales icon in the left bar <---- .

    Please Use Naming Conventions in your projects! ------\/
    http://www.visibleprogress.com/vb_na...onventions.htm

    Me to Brother
    -Hey, look at this avater I made in about 5 seconds
    -What, morrisons?
    -AGHHHHHH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width