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

TerminateProcess not working

Thu Feb 08, 2024 8:25 pm

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: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: TerminateProcess not working

Wed Feb 14, 2024 2:35 pm

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

Wed Feb 14, 2024 5:23 pm

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: 6506
Joined: Wed Jun 13, 2018 7:49 am

Re: TerminateProcess not working

Fri Feb 16, 2024 9:44 am

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.98KiB)Viewed 2970 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.03KiB)Viewed 2970 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

Fri Feb 16, 2024 4:24 pm

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.39KiB)Viewed 2965 times

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

Re: TerminateProcess not working

Mon Feb 19, 2024 2:44 pm

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”