Page 1 of 1

[SOLVED] Simple package for screen mirroring

Published: May 15, 2024 - 10:02 AM
by gaelds
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.

[Solved] Simple package for screen mirroring

Published: May 15, 2024 - 10:14
by gaelds
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...