[SOLVED] Creating a printer package (via PowerShell run)

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
Locked
LMS
Messages: 5
Registration: June 3, 2020 - 11:22

June 3, 2020 - 11:46

Hello everyone,

- Installed WAPT version: 1.8.0
- Server OS: Debian 10 (VM on Proxmox)
- Operating system of the administration/package creation machine: Windows 10

This is why I am coming to you:

I'm trying to create a package for installing our printer. So I did a first test on my administration machine. By that I mean I opened PowerShell, typed the commands one by one that allowed me to add and install the driver, create the print port, and create the printer in Windows.

Everything works from powershell, live on the administration machine, but when executing powershell commands in my package script, it no longer works, and this from the very first line.

Here is my PyScripter code (the powershell commands work as is when not executed by pyScripter).

Code: Select all

    run('powershell pnputil.exe -i -a T5DSETWin_10110FR\Drivers\PCL6\Win_x86\KOAXTJ__.inf')
    run('Add-PrinterDriver -Name "KONICA MINOLTA C287SeriesPCL"')
    run('powershell Add-PrinterPort -Name "IP_192.168......." -PrinterHostAddress "192.168....."')
    run('powershell Add-Printer -Name "5thFloor Printer" -DriverName "KONICA MINOLTA C287SeriesPCL" -PortName IP_192.168......"')
The first line doesn't work. The error:
Failed to add driver package: The INF file passed as a parameter is invalid.
I also tested `run_notfatal` to see the following lines. They also seem to be showing errors.

However, it works perfectly fine from PowerShell, starting from any line, since the drivers are installed etc. on the administration machine. (Same problem with x64, same problem if I change directories to exit waptdev, etc...)


I suspect an encoding error, but I admit I'm at a loss to analyze what's happening. And for good reason: here's the error message from the second line.
No positional parameter could be found that accepts the argument ®ÿC287SeriesPCLÿ¯.

Do you have any suggestions for a solution?

PS:
As a beginner, my ultimate goal isn't necessarily to successfully install this particular package, but rather to understand how everything works together. Therefore, there might be things in my approach that you find surprising. Feel free to point them out, even if they slightly deviate from the main topic: the printer installation package issue.

PS2: Could a PowerShell script solve the problem? I was too lazy to do it because I would have had to sign my script, since unsigned scripts are blocked from running. And then I figured that if it's possible to develop everything in PyScripter, it might be better than using a script linked in the package. Since I'm not familiar with development, my attempts are cautious, and learning is slow.
I would have liked, among other things, to test the existence of the print port before its creation, but I didn't want to write a gigantic line, and I don't know if it's possible to write a piece of PowerShell code over several lines in the Python script of the package.
User avatar
sfonteneau
WAPT Expert
Messages: 2318
Registered: July 10, 2014 - 11:52 PM
Contact :

June 3, 2020 - 12:17

To save you some time, I have a working printer installation package here:

https://wapt.lesfourmisduweb.org/list_p ... ll-printer
LMS
Messages: 5
Registration: June 3, 2020 - 11:22

June 9, 2020 - 12:04

Please excuse my late reply. I have a lot on my plate at the moment.

Perhaps it's because I downloaded the drivers again and used the new zip file. Or maybe I misunderstood what was missing for it to work via PowerShell (first time I've installed a printer via script/GPO/etc.^^).

In any case, your script works and is much cleaner than mine! And most importantly, it's adaptable for when I need it!

Thank you :).
Locked