#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    4
    Rep Power
    0

    Closing an External Program


    Hi everyone,

    This is my first post in this forum, so hopefully you'll be able to help.

    Basically what I am trying to do from within VB6 is to close an external program, from the exe name or the title.

    E.G. I'd like to close Notepad.exe or Untitled - Notepad.

    Does anyone know if this is possible...? and any source for it?

    Many thanks guys.
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2004
    Location
    Alaska
    Posts
    588
    Rep Power
    176
    To answer you question immediately, YES this is entirely possible. I have an example project on my other computer that I will upload for you as soon as I get home to it (couple hours).
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2003
    Posts
    508
    Rep Power
    18
    check out SysInternal's PsExec/PsTools...you can execute a shell command and kill a process...

    http://www.sysinternals.com/Utilities/PsTools.html

    http://www.sysinternals.com/Utilities/PsExec.html
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    4
    Rep Power
    0
    Originally Posted by baloodh2000
    To answer you question immediately, YES this is entirely possible. I have an example project on my other computer that I will upload for you as soon as I get home to it (couple hours).
    Many thanks... fingers crossed
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    4
    Rep Power
    0
    Originally Posted by BillyDunny
    check out SysInternal's PsExec/PsTools...you can execute a shell command and kill a process...

    http://www.sysinternals.com/Utilities/PsTools.html

    http://www.sysinternals.com/Utilities/PsExec.html
    Hi thanks for the reply. Whilst this may work, would prefer not to have to use external prog's/addins.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    4
    Rep Power
    0
    Hi again... found a really good example of what I was looking for. If anyone ever needed it can be found at

    http://www.freevbcode.com/ShowCode.Asp?ID=935
  12. #7
  13. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,442
    Rep Power
    4539
    Thanks for posting the link to your solution.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  14. #8
  15. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,638
    Rep Power
    4247
    I would use TerminateProcess() only as a last ditch effort. It is probably better to use SendMessage() and send a WM_CLOSE message to the process, so that it has a chance to quit cleanly first. TerminateProcess() is akin to yanking the rug out from underneath.

    Comments on this post

    • Axweildr agrees : For smoking on the boat ;)
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo