[SOLVED] Simple package for screen mirroring

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
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

May 15, 2024 - 10:02

Good morning,
To allow users who have forgotten the "Windows + P" combination to restore screen mirroring to the projector (1 or 2 tickets per week!), I created a very simple package based on the 'Portable Windows Application' template. The package copies an executable to Program Files and adds a desktop shortcut. This executable is a batch file converted to an executable that launches the command "C:\Windows\System32\DisplaySwitch.exe /clone".
The package installs correctly on 80 machines, but 4 of them still display this error:

Code: Select all

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\common.py", line 4096, in install_wapt
    packagetempdir = entry.unzip_package(cabundle=self.cabundle, target_dir = tempfile.mkdtemp(prefix='wapt',dir=self.wapt_temp_dir))
  File "C:\Program Files (x86)\wapt\waptpackage.py", line 2658, in unzip_package
    raise e
  File "C:\Program Files (x86)\wapt\waptpackage.py", line 2650, in unzip_package
    verified_by = self.check_package_signature(cabundle,ignore_missing_files=ignore_missing_files)
  File "C:\Program Files (x86)\wapt\waptpackage.py", line 2601, in check_package_signature
    errors = self.list_corrupted_files(ignore_missing_files=ignore_missing_files)
  File "C:\Program Files (x86)\wapt\waptpackage.py", line 2482, in list_corrupted_files
    elif hexdigest != _hash_file(fullpath, hash_func=hashlib.sha256):
  File "C:\Program Files (x86)\wapt\waptutils.py", line 758, in _hash_file
    buff_open = open(fname, 'rb')
OSError: [Errno 22] Invalid argument: 'C:\\Windows\\TEMP\\waptpkctalnb\\ClonerEcran\\ClonerEcran.exe'

22 : Invalid argument

The code for setup.py:

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
dir_name = 'ClonerEcran'
app_name = 'ClonerEcran'
app_exe = 'ClonerEcran.exe'
app_dir = makepath(programfiles32, dir_name)
app_path = makepath(app_dir, app_exe)
shortcut_name = "Cloner l'écran"

def install():
    # Installing software
    print("Installing: dst-cloner_ecran")
    killalltasks(control.get_impacted_process_list())
    mkdirs(app_dir)
    if isdir(app_dir):
        remove_tree(app_dir)
    mkdirs(app_dir)
    print("Copying directory: %s to: %s" % (dir_name, app_dir))
    copytree2(dir_name, app_dir)

    # Creating shortcuts
    create_desktop_shortcut(shortcut_name, app_path)
    create_programs_menu_shortcut(shortcut_name, app_path)

def uninstall():
    # Uninstalling software
    killalltasks(control.get_impacted_process_list())
    if isdir(app_dir):
        remove_tree(app_dir)

    # Removing shortcuts
    remove_desktop_shortcut(shortcut_name)
    remove_programs_menu_shortcut(shortcut_name)

def audit():
    # Getting installed software version
    if isfile(app_path):
        return "OK"
    else :
        return "ERROR"
I have re-uploaded the package several times without success.

PS: In the package template, I replaced the %% with % on the Print statements, otherwise it crashed at runtime.
Last edited by gaelds on May 15, 2024 - 10:15, edited 2 times.
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

May 15, 2024 - 10:14

Sorry, I just found the answer to my question by running `wapt-upgrade` on one of the four machines. Apparently, the Apex One antivirus agent is no longer working correctly on these machines, and it was Windows Defender that was blocking the package installation...
Answer