Pop-up to restart

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Answer
Carla Scardigli
Messages: 6
Registration: Apr 30, 2024 - 08:22

June 14, 2024 - 09:28

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
pop-up.png (5.29 KB) Viewed 3746 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?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 14, 2024 - 12:54

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
Carla Scardigli
Messages: 6
Registration: Apr 30, 2024 - 08:22

June 19, 2024 - 12:11

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?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 19, 2024 - 1:05 PM

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
Carla Scardigli
Messages: 6
Registration: Apr 30, 2024 - 08:22

June 19, 2024 - 2:16 PM

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?
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 25, 2024 - 09:30

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
Answer