0

Greeting All,

My development computer is located on the same network that my production apps are ran.

I have an app I developed called "Developer Tools" that allows me to handle many daily maintenance items. One of them is a listing of all executable showing a local timestamp and a server timestamp. Any item shown in yellow needs to be updated. Currently that would be RepayMonitor.exe, but as you can see the app is in use. I would like to be able to force the application closed (Early morning while this can be done, then notify the user to restart the app when they arrive). The only thing I know is the location of this file and that it is in use. Because it is located on another drive "K:\Frontline\CollectingIT\Bin\RepayMonitor.exe", I cannot use FindWindow() to grab a handle so I can close it. Does anyone know how to accomplish this knowing just the executable name and path? Any tips appreciated.

Developer Tools

STWizard
  • 31
  • 4
  • The drive where the executable is located is irrelevant. The computer where the code is being executed is what causes the issue you describe. Your question is actually *How do I close an executable running on a remote computer?*. You may want to edit to better convey the actual problem you're trying to solve. – Ken White Jan 13 '22 at 15:07
  • 1
    Thanks Ken, I have edited the title. – STWizard Jan 13 '22 at 15:19
  • 1
    How do you conclude "In Use" in code? Because that implies inspecting the remote process. And if you're able to do that, ending the process is most likely doable using the same API for remote actions. – AmigoJack Jan 13 '22 at 16:13
  • 1
    Rather than writing all this stuff yourself, why don't you use am off the shelf solution for updating software. – David Heffernan Jan 13 '22 at 18:22

1 Answers1

0

I think the more simple is to use Sysinternals suite and PsKill. You can use it in Delphi with a simple ShellExecute.

pskill [- ] [-t] [\\computer [-u user] [-p passwd]] process_name | process_id

To kill a process on a remote system requires administrative privileges on the remote system.

Examples:

Kill all instances of notepad.exe running on \\workstation64:
pskill \\workstation64 notepad
Bosshoss
  • 783
  • 6
  • 24