CUPS Printer added using command prompt is not working with authentication - printing

I have a CUPS server setup in Linux.I want to add this printer to my windows programmatically. Manually I am able to add.By searching various forums I found the following command:
rundll32 printui.dll,PrintUIEntry /if /b "TestPrinter_With_Auth" /f %windir%\inf\ntprint.inf /r "https://username:pasword#ipp.devCups.com/printers/Printer" /m "HP Color LaserJet 2500 PCL6 Class Driver"
I could install Printer using this command. But I couldn't Print to CUPS as it is not recognizing the credentials. I get access denied.
Any suggestion to achieve this programmatically.
Thanks in Advance
Matt

Related

Adding printer on windows-docker

We are trying to dockerize some old powerbuilder batch jobs, and the existing code requires a ghostscript printer installed with the exact name (for the details see here)
Microsoft's documentation on Print Spooler in containers
states "apps that have a dependency on installing printer drivers into the host cannot be containerized because driver installation from within a container is unsupported"
I do not know if this is just a typo/missunderstanding, as why would any application want to install driver into host? I need it in the container, also is it only for the drivers or for the Printers as well?
Assuming this is only a typo/missunderstanding, and microsoft claims it can not be done in the container, the question is
could I do it through the host (and commit it into a new docker image)
could I do it through doccker file , using some MSI installer and run it there
is there any possibility to add a driver and printer in docker image ? (and if not it should be clearly stated)
Assuming this the above statement is not a typo/missunderstanding, than it should be possible to add printer to docker. For that we are using
FROM mcr.microsoft.com/windows:1909
and isolation is hyperv
We tried runnig this from the dockerfile
RUN powershell -command Add-Printer -Name \"Test Printer\" -DriverName \"Microsoft Print to PDF\" -PortName \"PORTPROMPT:\"
and get following errror
# InvalidData: (MSFT_Printer:ROOT/StandardCimv2/MS
# FullyQualifiedErrorId : HRESULT 0x80070006,Add-Printer
but I was not able to find anything meangifull for this error
I can list, rename and remove a printer but I can not add existing one, also if I execute
Get-PrintConfiguration "Microsoft Print To PDF"
I am getting
+ CategoryInfo : NotSpecified: (MSFT_PrinterConfiguration:ROOT/StandardCi...erConfiguration) [Get-PrintConfiguration], CimException
+ FullyQualifiedErrorId : HRESULT 0x8000ffff,Get-PrintConfiguration
so it seams there is something fishy with printers in the docker image.
Do you if there is any possibility to add printer to docker image / container?
thanks
almir
Probably your error in in the DockerFile command. You have to pass the hole command to the powershell and not just the Add-Printer.
I did not try it out, but i would do it like this:
RUN powershell -command "Add-Printer -Name \"Test Printer\" -DriverName \"Microsoft Print to PDF\" -PortName \"PORTPROMPT:\""
The question is quite old, but i would be curios to have a beedback :)

Printer Port configuration using redmon and ghostscript, error invalid window handle

I want to print to pdf using Redmon and Ghostscript on windows 10, for which i added a new printer(set drivers to ghostpdf.inf) and added redirection port(RPT1). Now when i configure this port i get the error Invalid window handle, please check the picture. Thanks
Okay you need admin rights -
edit port configuration using cmd as admin with command -
printui.dll PrintUIEntry /p /n "printer name"
It is much better and more stable if you create a new port via "Print Management" of Windows, not via Printer Properties window

make an lp script into functioning printer

I'm trying to print to separate printers simultaneously in Ubuntu 14.04
From all of my reading the best option I've seen is to write a script
that sends an lp command to the separate printers.
This is the script I've written so far
!/bin/bash
lp -d printer "$#"
lp -d printer2 "$#"
where printer and printer 2 are the actual printers installed on the system
This script works from a terminal, however I would like to be able to send print jobs directly to a "printer" that is actually the script I've written.
How can I make this lp script into a "printer"
Ok I didn't find a way to do this the way I originally intended, however it is possible with tea4CUPS
great cups backend tool with an easy config file
http://www.pykota.com/software/tea4cups/download
The install instructions are on the download page.
As for printing to multiple printers, add this command in the config file for every printer you wish to print to.
prehook_firstprinter: /usr/bin/lp -d Name of Printer -o raw $TEADATAFILE
Here are the simplest instructions I could write
1. download the tea4cups.gz
Extract it to the home folder, rename it to tea4cups
Open a terminal and run these commands
sudo cp /home/manifester/tea4cups/tea4cups.conf /etc/cups
sudo cp /home/manifester/tea4cups/tea4cups /usr/lib/cups/backend/
sudo chmod 700 /usr/lib/cups/backend/tea4cups
Run this command
sudo gedit /etc/cups/tea4cups.conf
Paste this in the bottom of the document
prehook_firstprinter: /usr/bin/lp -d Name of Printer yes the literal name in the printer window -o raw $TEADATAFILE
you will need a new line for every printer you have, so if you want to print to 3 printers you will need three of the above line each having the name of the printer it will be talking to.
save and close everything
open a terminal and run
sudo service cups restart
open a web browser and go to the browser cups controller
http://localhost:631/admin
go to Add Printer
you should see a printer named "tea4CUPSnothing"
If you don't see it go back and press "Find Printers"
it should be there
Change the info of the printer to "Print all" for all type fields"
Press Continue
The generic printer driver works because the printer doesn't actually exist.
Press Continue
Set Defaults
you should be done, go to your printer window on ubuntu and do a test print.

Script to add network printer to all users x64 bit print server

I use to use this script for Windows XP but since we're doing the switchover to 7 I tried to use it on the new images. It seems like it tries but it doesn't work. I have created a 64bit print server and these machines are 64bit which is the only difference. I read up on this and saw there was a GPO that needed to be set to allow this to work. Which was - Computer Configuration > Administrative Templates > Printers > Allow Print Spooler to accept client connections.
I have tried everything and can't get this to work, it doesn't give me an error or anything. It gives me the prompts for PC name and Printer name, then says 'Adding printer' from the echo command, and just sits there. I can run the command by itself and it doesn't work either....... Please help!
The main thing is that the printer needs to be added from a print server and to the computer for all users as their default.
#echo off
echo PC Name
set /p PC=
echo Printer Name
set /p PRINTER=
ECHO Adding Printer...
\\ghostserver\installs\pstools\psexec \\%PC% -n 3 cmd /c rundll32
printui.dll,PrintUIEntry /y /ga /c\\%PC% /n\\PRINTSERVER\%PRINTER%
ECHO Restarting Print Spooler...
start /wait sc \\%PC% stop spooler
start /wait sc \\%PC% start spooler
Do you want to install or map the printer from the network ?
First thing to try : map the printer manually on a 7 x64 client. If it fails, your problem is not the batch.
Also try the simple rundll32 printui.dll PrintUIEntry /in n\\PRINTSERVER\%PRINTER% with a non-admin non-elevated account on the client to validate the print server configuration.
Is the "Disallow installation of printer using kernel-mode drivers" GPO disabled ? (Have to be)
Check the firewall settings, UAC/elevation configuration, admin access. Run a gpupdate /force and restart the client.
Check the event log on both the client and print server for any errors.
With an admin account (both print server and client), try to push the installation from the print server.
Have you tried to force adding the provider ? /j "LanMan Print Services"
If you have 2008 servers or DCs, you can use Print Management or Group Policy Preferences to deploy printers (easier than bat+psexec+printui.dll).
If you really want to do it via login script, there are also a bunch of tools in Vista/7/8 for print management in %WINDIR%\System32\Printing_Admin_Scripts, like this one.
Side note : start /wait is inefficient since sc.exe doesn't wait any response of the service. So, if you stop and start without a pause, chances are the service will not be stopped before the restart and skip the second order. You have to simulate a pause (ping 127.0.0.1 -n 5 >nul 2>&1) between stop & start or use a safer script to check the state of the service.
Thank you so much! That fixed it.
Here's my add script:
#echo off
echo PC Name
set /p PC=
echo Printer Name
set /p PRINTER=
echo Adding Printer...
\\servername\installs\pstools\psexec -s -i -accepteula \\%pc% rundll32 printui.dll PrintUIEntry /in /y /ga /n\\PRINTSERVER\%PRINTER%
echo Restarting Print Spooler...
start sc \\%pc% stop spooler
pause
start sc \\%pc% start spooler
pause
Here's my remove script:
#echo off
echo PC Name
set /p PC=
echo Printer Name
set /p PRINTER=
echo Adding Printer...
\\servername\installs\pstools\psexec -s -i -accepteula \\%pc% rundll32 printui.dll PrintUIEntry /gd /n\\PRINTSERVER\%PRINTER%
echo Restarting Print Spooler...
start sc \\%pc% stop spooler
pause
start sc \\%pc% start spooler
pause

Script to check if printer exists locally, and if so, deletes it

I'm writing a windows batch file and need to check whether the print exists on the local computer, and if so, deletes the mapped printer from the computer. Here is the code that I'm using to delete the printer.
RUNDLL32 printui.dll,PrintUIEntry /n \\server\printerName /dn
This works fine, but now I need a conditional statement before this so I check if that printer exists first. Then run that line. I'm not sure how to write this.
You could try something like this, just replace the string to find with the printer you want to find.
For /F "Tokens=4 delims=\" %%I In ('reg query HKCU\Printers\Connections ^|find /I "560C"') Do If "%%I"==",,ServerName,HP DeskJet 560C" goto :REMOVE
goto :SKIP
:REMOVE
RUNDLL32 printui.dll,PrintUIEntry /n \\server\printerName /dn
:SKIP
Or just run the command and if it doesn't exist it will error, if it does it will work?
Hope this helps!
You can just skip the check and run your deletion command anyway.
To suppress the error popup just add the /q option as specified in the rundll32 printui.dll documentation.
this yields:
RUNDLL32 printui.dll,PrintUIEntry /n \\server\printerName /dn /q

Resources