Page 1 of 1
Pop-up to restart
Published: June 14, 2024 - 09:28
by Carla Scardigli
Good morning,
Is it possible to implement a pop-up system in a WAPT package?
We would like a pop-up to appear on the user's screen.
This pop-up would be used to restart the machine. The user must be able to interact with it.
Here is an example of what we want:

- pop-up.png (5.29 KB) Viewed 3754 times
And here is the code:
Code: Select all
import ctypes
MB_YESNO = 0x04
MB_ICONQUESTION = 0x20
IDYES = 6
IDNO = 7
reponse = ctypes.windll.user32.MessageBoxW(0, message + "voulez-vous redémarrer la machine maintenant ?", "Redémarrage", MB_YESNO | MB_ICONQUESTION)
if reponse == IDYES:
subprocess.call(["shutdown", "-r", "-t", "0"])
If the user clicks "Yes" the machine should restart, otherwise nothing happens.
When we run the script, the pop-up does not appear on the machine.
Can the "session_setup" function help us, and if so, how?
Re: Pop-up to restart
Published: June 14, 2024 - 12:54
by sfonteneau
Good morning
Carla Scardigli wrote: ↑June 14, 2024 - 09:28
When we run the script, the pop-up doesn't appear on the machine.
Can the "session_setup" function help us, and if so, how?
The code you mentioned will work, but only in session_setup
Take a look at this package for an example:
https://wapt.tranquil.it/store/fr/detai ... _PROD.wapt
Re: Pop-up to restart
Published: June 19, 2024 - 12:11
by Carla Scardigli
Good morning,
Indeed, putting the "pop _up" function in the "session_setup" works.
What we want to do is uninstall an application from the machine, and then once it is uninstalled, we want to ask the user if they want to restart the machine using the pop-up.
Here is the code for "session_setup" which allows uninstallation:
Code: Select all
print('Arrêt de la tâche en cours...')
killalltasks('ssmon.exe')
time.sleep(5)
#Désinstallation et nettoyage
remove_file(log_path + r'\APP.LOG')
run(install_path + r'\unins000.exe /VERYSILENT')
remove_tree(install_path)
# Pop up qui demande à l'utilisateur s'il veut redémarrer la machine
pop_up()
When we run it, nothing happens, no pop-up appears, the package starts executing and then goes into "OK" status without proceeding with the uninstallation.
The problem is that the "install" function does not have the same privileges as the "session_setup" function because the latter inherits the user's rights. A user does not have the rights to install or uninstall software.
Is there a way to encapsulate the "session_setup" function within the "install" function? Would this solution resolve the permissions issue?
How can we make this work?
Re: Pop-up to restart
Published: June 19, 2024 - 1:05 PM
by sfonteneau
In the example I sent in my previous message, there is:
Code: Select all
from waptservice.enterprise import get_active_sessions, start_interactive_process
def run_session_setup(package_name):
for session_id in get_active_sessions():
start_interactive_process("wapt-get", "--hide session-setup %s -f" % package_name, session_id=session_id) # , minimize=True
This launches code execution in open sessions
In this specific case, it launches:
wapt-get --hide session-setup tis-toto -f
but you can launch whatever you want
Re: Pop-up to restart
Published: June 19, 2024 - 2:16 PM
by Carla Scardigli
Hello,
I'm not sure I understand how to use this code.
Should I put my pop-up code in the "run_session_setup" function? How do I use this function?
What are the "get_active_sessions" and "start_interactive_process" arguments for?
Re: Pop-up to restart
Published: June 25, 2024 - 09:30
by sfonteneau
Carla Scardigli wrote: ↑June 19, 2024 - 2:16 PM
Should I put the code for my pop-up in the "run_session_setup"?
Yes, that's it
Carla Scardigli wrote: ↑June 19, 2024 - 2:16 PM
What are the "get_active_sessions" and "start_interactive_process" arguments used for?
get_active_sessions: retrieves the current (open) sessions
start_interactive_process: used to launch code in the open session (session_id)
in this case :
wapt-get --hide session-setup tis-toto -f