kburndred
Posts: 3
Joined: Wed Feb 07, 2024 11:05 pm

TerminateProcess not working

I have tried TerminateProcess and cannot get it to work on a background process.

Seems to work fine for applications running within the current user context but not background processes.

Information:
My project is set for "Run as Administrator"
The background process is started by a scheduled task in windows.
I have tried to detect the process right before and then terminate process, still not work.
I have also tried close application, also not work.

Any help would be greatly appreciated.

Thanks
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: TerminateProcess not working

Hello and welcome to our forums,

Since your process is started by a scheduled task, I would assume it might run under the LocalSystem account.

Have you tried having your Custom Action scheduled after the "Preparing" action group with its' Execution Time set to "When the system is being modified" and "Run under the LocalSystem account with full privileges (no impersonation)" option checked?

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kburndred
Posts: 3
Joined: Wed Feb 07, 2024 11:05 pm

Re: TerminateProcess not working

Hello Catalin,

I don't see a "Preparing" group or "Execution Time" and the option to run as LocalSystem..... is greyed out.

My project was created under trial version and then converted to full license. Could this be the issue?

If so how can I resolve that?

Thanks
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: TerminateProcess not working

Hello,

If possible, could you please forward me a screenshot of your Custom Actions page?

The "Preparing" action group should be there by default.
Screenshot_106.png
Screenshot_106.png (10.98 KiB) Viewed 3641 times

Regarding the option being greyed out, please keep in mind that the "Execution Time" has to be set as "When the system is being modified (deferred)" in order for the "Run under the LocalSystem account with full privileges (no impersonation)" to be enabled.
Screenshot_107.png
Screenshot_107.png (26.03 KiB) Viewed 3641 times

Hope this helps!

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
kburndred
Posts: 3
Joined: Wed Feb 07, 2024 11:05 pm

Re: TerminateProcess not working

I was able to get things working as below;

Q: Is there a way to know if an app/process fails to close?
advanced-installer-000.png
advanced-installer-000.png (136.39 KiB) Viewed 3636 times
Catalin
Posts: 6608
Joined: Wed Jun 13, 2018 7:49 am

Re: TerminateProcess not working

Hello,

I am glad to hear you got this working!
Q: Is there a way to know if an app/process fails to close?
Here, we could make use of the "Detect process" custom action that will return the state of the process. If we execute the Stop Process custom action and then the state of the process is still "running", we can assume it failed to close.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”