
Printer Import
Paquet d’installation silencieuse pour Printer Import
20.1.2-8
- package: tis-printer-import
- name: Printer Import
- version: 20.1.2-8
- categories: System and network,Drivers,Configuration
- maintainer: WAPT Team,Tranquil IT,Simon FONTENEAU,Jimmy PELÉ
- locale: all
- target_os: windows
- architecture: all
- signature_date:
- size: 11.93 Ko
package : tis-printer-import
version : 20.1.2-8
architecture : all
section : base
priority : optional
name : Printer Import
categories : System and network,Drivers,Configuration
maintainer : WAPT Team,Tranquil IT,Simon FONTENEAU,Jimmy PELÉ
description : Printer Import - To prepare this package, just run update-package, the package will suggest you a recommended process. You can run this update-package from the waptconsole if running as local administrator
depends :
conflicts :
maturity : PROD
locale : all
target_os : windows
min_wapt_version : 2.2
sources :
installed_size :
impacted_process :
description_fr : Printer Import - Pour préparer ce paquet, il suffit de lancer update-package, le paquet vous proposera un processus recommandé. Vous pouvez exécuter ce paquet de mise à jour à partir de la waptconsole si vous êtes un administrateur local
description_pl : Printer Import - Aby przygotować ten pakiet, wystarczy uruchomić update-package, pakiet zasugeruje ci zalecany proces. Możesz uruchomić ten update-package z konsoli waptconsole, jeśli pracujesz jako lokalny administrator
description_de : Druckerimport - Um dieses Paket vorzubereiten, führen Sie einfach update-package aus, das Paket wird Ihnen einen empfohlenen Prozess vorschlagen. Sie können dieses Update-Paket über die Waptconsole ausführen, wenn Sie als lokaler Administrator arbeiten
description_es : Importación de impresoras - Para preparar este paquete, simplemente ejecute update-package, el paquete le sugerirá un proceso recomendado. Puede ejecutar este paquete de actualización desde la consola de wapt si se ejecuta como administrador local
description_pt : Importação de impressoras - Para preparar este pacote, basta executar o update-package, o pacote irá sugerir-lhe um processo recomendado. Pode executar este update-package a partir da waptconsole se estiver a correr como administrador local
description_it : Importazione della stampante - Per preparare questo pacchetto, è sufficiente eseguire update-package; il pacchetto suggerirà un processo consigliato. È possibile eseguire questo pacchetto di aggiornamento da waptconsole se si opera come amministratore locale
description_nl : Printer Import - Om dit pakket voor te bereiden, draai je gewoon update-package, het pakket zal je een aanbevolen proces voorstellen. Je kunt dit update-pakket uitvoeren vanuit de waptconsole als je als lokale beheerder werkt
description_ru : Импорт принтера - Чтобы подготовить этот пакет, просто запустите update-package, пакет предложит вам рекомендуемый процесс. Вы можете запустить этот пакет обновления из консоли waptconsole, если работаете от имени локального администратора
audit_schedule :
editor :
keywords :
licence :
homepage :
package_uuid : e61e579d-fe99-4691-ad5b-4e43f95f50c6
valid_from :
valid_until :
forced_install_on :
changelog :
min_os_version : 6.0
max_os_version :
icon_sha256sum : 517a7d6d960a2704c2f345af02a919deadc207ca910c7f5c6c3a1965bf6f64ad
signer : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature : y5G10Pk2IcbKq11UbMJ9m4wXuJElTdygWsi8bMiv671l3JBzJ9Cl4/M/LUmCHRhZ1woOMQ+UTkaMRrInQuXxGCwIiwf1P/0Sgp+AQQZEiB/086q2pwU4D1tJTTSrLITjVM8GM52c9zRQjFpGMcdXK5m20nchqS0G4dU/vqOwshP9h/ru8tafORhz/mpua/ejn0gac1QGhGbJFmbfMo1OgaRFSmDlvvImYwFnUlBi2Tgcs+uKt/6itVressLxM0joTzTrCg0lhE0IrE3UBMiYVkPRWRkrNN4EkcOztrfIgd7ZSSPAyD5QKq7bzD3Psb/gUifrwhAb0H9aFRPJlmnikg==
signature_date : 2022-07-29T04:28:09.098188
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
# -*- coding: utf-8 -*-
from setuphelpers import *
r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
https://docs.microsoft.com/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/jj134237(v=ws.11)
PrintBrm -B|R|Q [-S <server>] -F <file> [-D <directory>] [-O FORCE] [-P ALL|ORIG] [-NOBIN] [-LPR2TCP] [-C <config file>] [-NOACL] [-?]
-B Backup the server to the specified file
-R Restore the configuration in the file to the server
-Q Query the server or the backup file
-S <server name> Target server
-F <file name> Target backup File
-D <directory> Unpack the backup file to (with -R) or repack a backup file from (with -B) the given directory
-O FORCE Force overwriting of existing objects
-P ALL|ORIG Publish all printers in directory, or publish printers that were published originally
-NOBIN Omit the binaries from the backup
-LPR2TCP Convert LPR ports to Standard TCP/IP ports on restore
-C <file name> Use the specified configuration file for BRM
-NOACL Remove ACLs from print queues on restore
-? Display this help
https://docs.microsoft.com/powershell/module/printmanagement/get-printer
Name ComputerName Type DriverName PortName Shared Published DeviceType
---- ------------ ---- ---------- -------- ------ --------- ----------
Printer1 Local HP Universal Printing PC… IP_192.168.0.1 False False Print
Microsoft Print to PDF Local Microsoft Print To PDF PORTPROMPT: False False Print
To prepare this package, just run update-package, the package will suggest you a recommended process. You can run this update-package from the waptconsole if running as local administrator
"""
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
printbrm_path = makepath("%windir%", r"System32\spool\tools\PrintBrm.exe")
windows_temp_dir = makepath(systemdrive, "Windows", "Temp")
printers_export_file = "export.printerExport"
printers_export_path = makepath(windows_temp_dir, printers_export_file)
printers_backup_file = "backup.printerExport"
printers_backup_path = makepath(windows_temp_dir, printers_backup_file)
printers_manual_backup_file = "manual_backup.printerExport"
printers_manual_backup_path = makepath(windows_temp_dir, printers_manual_backup_file)
to_import_printers_list = ["Printer1"] # To fill manually if you want the package to being able to uninstall imported printers
force_config = True # Forces overwriting of existing objects.
def install():
# Force config is requested
if force_config:
printbrm_option = "-O FORCE"
else:
printbrm_option = ""
# Installing printers with drivers and configuration
print(run(r'"%s" -r -f %s %s' % (printbrm_path, printers_export_file, printbrm_option)))
def uninstall():
for printer_name in to_import_printers_list:
remove_printer(printer_name)
# -*- coding: utf-8 -*-
from setuphelpers import *
import waptguihelper
import json
import win32con
# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls
printbrm_path = makepath("%windir%", r"System32\spool\tools\PrintBrm.exe")
windows_temp_dir = makepath(systemdrive, "Windows", "Temp")
printers_export_file = "export.printerExport"
printers_export_path = makepath(windows_temp_dir, printers_export_file)
printers_backup_file = "backup.printerExport"
printers_backup_path = makepath(windows_temp_dir, printers_backup_file)
printers_manual_backup_file = "manual_backup.printerExport"
printers_manual_backup_path = makepath(windows_temp_dir, printers_manual_backup_file)
def update_package():
# Admins only
if not running_as_admin():
error("This update_package must be run as local administrator")
# When to backup
if not isfile(printers_manual_backup_path):
console_warning = messagebox(
control.package,
"Do you want to use the backup before Print Management (printmanagement.msc)? By pressing no the backup will just occur after Print Management",
win32con.MB_YESNOCANCEL,
)
if console_warning == 2:
error("Cancelled")
elif console_warning == 6:
# Manual Backup if choisen
print(run(r'"%s" -b -f %s' % (printbrm_path, printers_manual_backup_path)))
user_backup_path = makepath(user_desktop, printers_manual_backup_file)
filecopyto(printers_manual_backup_path, user_backup_path)
print("Manual backup located at: %s" % user_backup_path)
# Delete file to prevent futur further interaction
# remove_file(user_backup_path)
# print("Place breakpoint here and copy above code for manual backup")
# Print Management
run("printmanagement.msc")
# Get printers_list
printers_list = []
for u in json.loads(list_local_printers()):
for p in u:
if p:
if not type(p) == int:
if not p.split(",")[0] in printers_list:
printers_list.append(p.split(",")[0])
# Printers to export
printers_dict_list = []
if windows_version(2) >= "10.0":
printers_dicts = run_powershell("Get-Printer")
# Formatting dict
key_list = ["Name", "DriverName", "PortName", "PrintProcessor", "PrintProcessor", "Published", "Shared"]
for p in printers_dicts:
for key in list(p.keys()):
if key not in key_list:
del p[key]
printers_dict_list.append(p)
selected_printers = json.loads(
waptguihelper.grid_dialog(
"Select printers by deleting printer that you won't import",
json.dumps(printers_dict_list),
)
)
else:
for p in printers_list:
d = {"Name": p}
printers_dict_list.append(d)
selected_printers = json.loads(
waptguihelper.grid_dialog(
"Select printers by deleting printer that you won't import",
json.dumps(printers_dict_list),
)
)
# Backup
if not isfile(printers_manual_backup_path):
if isfile(printers_backup_path):
remove_file(printers_backup_path)
print(run(r'"%s" -b -f %s' % (printbrm_path, printers_backup_path)))
# Preparing to export
printers_to_export = []
for d in selected_printers:
printers_to_export.append(d["Name"])
for p in printers_list:
if p not in printers_to_export:
remove_printer(p)
clean_spooler()
# Export
if isfile(printers_export_path):
remove_file(printers_export_path)
print(run(r'"%s" -b -f %s' % (printbrm_path, printers_export_path)))
if isfile(printers_export_file):
remove_file(printers_export_file)
filecopyto(printers_export_path, printers_export_file)
# Restore
if isfile(printers_manual_backup_path):
printers_backup_path = printers_manual_backup_path
print(run(r'"%s" -r -f %s -o' % (printbrm_path, printers_backup_path)))
print(
"If the restoration of the previously installed printers (on this PC) failed, you may want to recover the backup file located: %s"
% printers_backup_path
)
def clean_spooler():
run("net stop spooler")
run(r"DEL /F /S /Q %systemroot%\System32\spool\PRINTERS\*")
run("net start spooler")
74ef1941dc797d1e788b6849e320add55c21b8622c8669dceeb8fe3f418322be : setup.py
dfa4d216d59fe7365e6a204105c383dc928a8d936792542696b2aee50c31bf7d : update_package.py
517a7d6d960a2704c2f345af02a919deadc207ca910c7f5c6c3a1965bf6f64ad : WAPT/icon.png
a5a97261381e1d0ad46ee15916abec9c2631d0201f5cc50ceb0197a165a0bbbf : WAPT/certificate.crt
402a7707258014be1ae7fe8e0c3465f2387028192d2cb69a2a8a3635311fe118 : WAPT/changelog.txt
8527ae04ec3a4f0675208cb307b03f5d3d9676a5649ed31f80558767ca46e008 : luti.json
f9f25b0c1d36a655ffc920be27f501e0762446c4ad041a14200dff71d0832f4f : WAPT/control
20.1.2-7
Minimum version is now Windows Vista/2008, code adapted
Manual backup is now master backup and should be manually deleted if the adminsys change his mind
20.1.1-6
update-package from console is now the same as from editor
20.1-5
Now a manual backup can be done
20.0-0
Initial package