Unable to install printer
-
@sebastian-roth We need detailed log of printui command result.
The command in the client code is the same I have used to test from command line (test was ok), so it’s strange it doesn’t work. -
@tatanas Maybe there is some message in the Windows event log? Just a quick idea from the top of my head. I will try to find some time to help you on getting fog-client compiled soon as well.
-
@sebastian-roth I checked Windows event log (spooler log) and didn’t find anything regarding the printer installation.
Thanks for your time. -
Ok, thanks to you I can build the Fog Client (https://forums.fogproject.org/topic/15757/fog-client-build).
I would like to log the result of the printui command in WindowsPrinterManager.cs at line 41.
I added “> c:\printui.log” but it doesn’t work.using (var proc = Process.Start("rundll32.exe", $" printui.dll,PrintUIEntry {cmdLine} > c:\\printui.log"))
I don’t know C# so I suppose I could use a method to get Standard Output ?
-
@tatanas This answer on stackoverflow looks promising: https://stackoverflow.com/a/18529868
-
@sebastian-roth Here are the changes I made in the WindowsPrinterManager.cs at line 41:
using (Process proc = new Process()) { proc.StartInfo.FileName = "rundll32.exe"; proc.StartInfo.Arguments = $" printui.dll,PrintUIEntry {cmdLine}"; proc.StartInfo.RedirectStandardOutput = true; proc.StartInfo.UseShellExecute = false; proc.Start(); var output = proc.StandardOutput.ReadToEnd(); proc.WaitForExit(30*1000); if (proc.HasExited) { Log.Entry(LogName, "PrintUI return code = " + proc.ExitCode); Log.Entry(LogName, "PrintUI Output = " + output); } else { Log.Entry(LogName, "PrintUI has not finished in a timely fashion, abandoning process"); } }
replacing
using (var proc = Process.Start("rundll32.exe", $" printui.dll,PrintUIEntry {cmdLine}")) { ... }
Unfortunatly, printui does not return anything…
Logging the “cmdLine” variable returns this when the first installation attempts:
cmdLine = /if /b "B503-LASER (fog)" /f "\\@IP_NAS\applications\Imprimantes\HP_LJ_M401\hpcm401u.inf" /r "IP_X.X.X.X" /m "HP LaserJet 400 M401 PCL 6" /q
After that, cmdLine is not used anymore and we’ve got “already configured”.
I never pass in the procedurepublic override void Configure(Printer printer, bool verbose = false) { ... }
-
I made some tests. The same printui command in local works fine.
So if it’s working in local it should works with fog client which means the added printer is removed/deleted from the host as soon as it’s installed ? It could explain why we can’t see the printer in the host list and why fog client says it’s already configured. -
Last news :
- The script never goes in the “Remove” method, so my last suggestion is wrong.
- I made a mistake about the “Configure” method. It is going into this method but it passes into
if (string.IsNullOrEmpty(printer.ConfigFile)) return;
and never execute
PrintUI($"/Sr /n \"{printer.Name}\" /a \"{printer.ConfigFile}\" m f g p", verbose);
EDIT : it is the same behaviour on a computer without problem… I’m lost
-
@tatanas said in Unable to install printer:
I never pass in the procedure
public override void Configure(Printer printer, bool verbose = false)Can you please explain what you mean by that?
-
@sebastian-roth Sorry I made a mistake, like I said in my previous post, the “Configure” method is called but does nothing (always enter the second “if”).
-
This problem is very strange.
I was testing on a win7 computer which can’t install printers (fog client 0.12).
I push a old fog image on it and with the same 0.12 client, it now works.
It is not really up to date and the problem appears on win10 too (different version). -
@tatanas Maybe the changes that came when MS fixed the printer nightmare issue is causing the problem.
-
@sebastian-roth said in Unable to install printer:
Maybe the changes that came when MS fixed the printer nightmare issue
I had to deal with this last week on my campus. (TBH I only skimmed this thread, so this may be a bit off point). The windows accumulative patch for September for both the servers and workstations broke printing for me on the older legacy systems. If you have a currently supported and fully patch version of 2012, 2016, 2019, or what ever is being patched on windows 10 printing worked normally. If you had anything less than 2012 or unpatched win10 or less the users could not print to a current windows print server or install new printers.
It appears in the sept patch MS turned on encrypted communications on the print spooler. I can’t find the article I found at the moment but the workaround is to disable the encryption using the registry key here: https://borncity.com/win/2021/09/20/windows-september-2021-update-workaround-fr-druckprobleme/ Look at the post by Benjamin. I’m not saying this is your problem here with the fog client, but setting this registry value to 0 will allow legacy windows devices to print to contemporary windows print spoolers.
-
Unfortunately, the problem is still the same after changing 2 registry keys :
(printer nightmare)
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint]
“RestrictDriverInstallationToAdministrators”=dword:00000000[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print]
“RpcAuthnLevelPrivacyEnabled”=dword:00000000 -
New test : After upgraded a Windows 7 host (Fog printer ok) to Windows 10, Fog printer installation didn’t work anymore.
-
And another one :
Using the printui command (same as the one used in client source code) remotely with psexec, generate a rights error from windows when -s argument is used (execute as system account).
As administrator, the printer is installed fine.How fog client executes the printui command localy ? as system or logged on user ?
-
EUREKA !
In the Fog service properties, I change the “Open session as” in Connection Tab from “Local system account” to “Administrator” with his current password.
Then I reset the client Encryption Data on the Fog web console, restart the Fog client service and Voilà ! All printers are installed.Now we need to find why this problem appears “randomly” on host which was working fine ?
-
@tatanas Great work!!!
Using the printui command (same as the one used in client source code) remotely with psexec, generate a rights error from windows when -s argument is used (execute as system account).
As administrator, the printer is installed fine.You hit the nail on the head with this finding I reckon! It’s probably something MS changed due to the printer nightmare findings/issues that is now breaking the printer install through SYSTEM account (used to run FOGService).
We’ll need to do more research on this particular point and I am fairly sure we’ll find others in a similar situation.
https://libredd.it/r/sysadmin/comments/ppdztz/microsoft_september_rollup_just_broke_around_122/
https://www.reddit.com/r/sysadmin/comments/p5inas/deploying_printers_to_users_post_print_nightmare/ -
@sebastian-roth Well well well… I just test the “fix” (change fog service to administrator access) on another computer and… it didn’t work.
I checked the KB installed too and the print nightmare one is not installed.It seems the problem is coming from the printui command executed as system account but why ?
I read that printui is not verbose at all (pretty hard to debug) and printer installation should be done with WMI (like the Port installation in the Fog Client source code).
I will continue my tests.
-
After few tests on different computers, the service trick seems to work. (I guess the failed computer was an exception…)
All the registry values related to nightmare patch don’t fix this problem.
There is something about the execution of printui as system account. And not all printui command because the one which delete printers (from Fog web console) works fine.