Additional features

Customizing the user environment

One of the main advantages of WAPT is the silent installation and uninstallation of software, even when restricted users are connected.

The WAPT agent runs with Windows SYSTEM rights, it allow to define global settings in system context and customized settings in restricted user mode.

User settings customization relies on the session_setup function defined in WAPT library Setuphelpers.

Working principle

User mode customization operates as follows:

  • the instructions are defined in session_setup() function of setup.py file;
  • when the package is deployed on the machine, instructions are stored in the local database of the WAPT agent;
  • when the user connects to her computer, session_setup customizations are executed in the limit of one execution per user and per WAPT package version;

Hint

session_setup customization will occur only once per user per package; a shortcut created in that context is created only once and not at every startup. To execute a task at each startup, it is preferable to define a Windows scheduled task to be launched by a local GPO or by a startup script.

session_setup customization will occur only once per user per package; a shortcut created in that context is created only once and not at every startup. To execute a task at each startup, it is preferable to define a Windows scheduled task to be launched by a local GPO or by a startup script.

Example: create a personalized desktop shortcut

One of the possibilities offered by SetupHelpers is adding personalized shortcuts on user desktops, instead of a desktop shortcut common to all users.

For that purpose, we will use the create_user_desktop_shortcut() function to create shortcuts containing the username and passing a website as an argument to Firefox.

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():
    print('installing tis-firefox-esr')
    install_exe_if_needed("Firefox Setup 45.5.0esr.exe",
                          silentflags="-ms",
                          key='Mozilla Firefox 45.4.0 ESR (x64 fr)'
                          min_version="45.5.0"
                          killbefore="firefox.exe")

def session_setup():
  create_user_desktop_shortcut("Mozilla Firefox de %s" % get_current_user(),
                               r'C:\Program Files\Mozilla Firefox\firefox.exe',
                               arguments="-url https://tranquil.it")

Deploying a portable software with WAPT

A good example of a WAPT package is a self-contained / “portable” software package:

  • create the folder for the software in C:\Program Files (x86);
  • copy the software in that folder;
  • create the shortcut to the application;
  • manage the uninstallation process for the application;
  • close the application if it’s running;

Example with ADWCleaner

  • create a group package and modify the control file to transform it to a software package;
wapt-get make-group-template tis-adwcleaner
package           : tis-adwcleaner
version           : 6.041-1
architecture      : all
section           : base
priority          : standard
maintainer        : Tranquil-IT Systems
description       : ADW Cleaner

The file C:\waptdev\tis-adwcleaner-wapt is created.

  • download and copy / paste adwcleaner.exe binary in C:\waptdev\tis-adwcleaner-wapt directory;
  • open and make desired changes to C:\waptdev\tis-adwcleaner-wapt\setup.py installation file;
# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

targetdir = makepath(programfiles32,'adwcleaner')
exename = 'adwcleaner_6.041.exe'

def install():
  mkdirs(targetdir)
  filecopyto(exename,targetdir)
  create_programs_menu_shortcut('ADWCleaner',target=makepath(targetdir,exename))
  # control est un objet PackageEntry correspondant au paquet en cours d'installation
  register_windows_uninstall(control)

def uninstall():
  killalltasks(exename)
  remove_programs_menu_shortcut('ADWCleaner')
  if isdir(targetdir):
      remove_tree(targetdir)
  unregister_uninstall('tis-adwcleaner')