Page 1 of 1

[RESOLVED] Using the start_interactive_process function for user interaction during deployment

Published: Dec 5, 2024 - 10:12 AM
by fobrien
Good morning,

I am taking the liberty of raising this topic following the post (viewtopic.php?p=14558#p14558) that I had opened regarding the possible interaction with users when deploying a package with WAPT.

Unfortunately, although my command line calling an external PowerShell script and allowing a popup to be displayed to the user worked perfectly when testing locally with PyScripter, it was a completely different story when deploying the package via WAPT because nothing was displayed.

So I wanted to adapt this PowerShell script call using the function start_interactive_process as Simon had indicated, and I managed to build the following command line which works perfectly locally with PyScripter:

Code: Select all

notification_folder = makepath(basedir, "Notification")

for session_id in get_active_sessions():
	popup=notification_folder + "\\PsExec.exe"
        popup_command_exec="-s powershell.exe " + notification_folder + "\\ServiceUI.exe C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoLogo -Noprofile -WindowStyle Hidden -file " + notification_folder + "\\Notification.ps1 -config " + notification_folder + "\\upgrade.xml"
        start_interactive_process(popup, popup_command_exec, session_id=session_id,minimize=True)
However, if I publish the package and test the deployment on a computer, I get this error message:

Picture

However, the directory in question is completely empty because it is used only occasionally and temporarily by the package, I think (I specify that all the necessary files are present in the package directory from the beginning).

My question is: is this phenomenon normal and what is the function start_interactive_process Is it capable of accessing files from the package's native directory?

Thanks in advance.

Fred

Re: Using the start_interactive_process function for user interaction during deployment

Published: Dec 5, 2024 - 10:53
by dcardon
Hi Frédéric,

I imagine you're calling this function within the `install()` function (it's best to have the entire script if possible). The package contents are unzipped into a temporary directory in `%TEMP%`. If `psexec.exe` is present in the package, it will be unzipped into the temporary directory. However, this is a file that is deleted on the fly by most antivirus programs, so you should check that first...

Best regards,

Denis

Re: Using the start_interactive_process function for user interaction during deployment

Published: Dec 6, 2024 - 3:48 PM
by fobrien
Hello Denis,

Thanks for your reply.
Indeed, the script is executed in the part def install(): And here is the complete code:

Code: Select all

def install():

	notification_folder = makepath(basedir, "Notification")

	for session_id in get_active_sessions():
		popup=notification_folder + "\\PsExec.exe"
        	popup_command_exec="-s powershell.exe " + notification_folder + "\\ServiceUI.exe C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoLogo -Noprofile -WindowStyle Hidden -file " + notification_folder + "\\Notification.ps1 -config " + notification_folder + "\\upgrade.xml"
        	start_interactive_process(popup, popup_command_exec, session_id=session_id,minimize=True)
        
        sys.exit(0)
I tried in parallel to create a directory accessible to all users locally, to copy the required executables into it (including "PsExec.exe") and then to call it from my Python script.
The script works perfectly from PyScripter, the directory is created correctly and the files are not deleted by the antivirus.

However, it also fails to work when executed as a package.

Are there any specific points to be observed with the function? start_interactive_process ?

Thanks in advance.

Fred

Re: Using the start_interactive_process function for user interaction during deployment

Published: Dec 10, 2024 - 4:21 PM
by fobrien
Hello,

I finally managed to resolve the issue by changing the command-line syntax, and the notification now displays correctly in the user context.
However, I opted for a scheduled, ephemeral task to avoid using the "PsExec.exe" and "ServiceUI.exe" processes, which are sometimes misinterpreted by EDRs in terms of behavior.

Fred

Re: Using the start_interactive_process function for user interaction during deployment

Published: January 12, 2026 - 11:58 PM
by luc91
I think your solution with the scheduled task was simpler in the end. It avoids the problems with PsExec and ServiceUI, especially with antivirus software or EDR that can block it.