Batch file preset input / printer problem
I am trying to import some printer settings via KScript / batch files.
I created a KScript where I run a batch file which then runs a 2nd batch file, and inputs a preset value in response to a prompt that comes up; in this case the number 1. If I run the batch file manually, the preset input value works correctly. When I run the batch file via my KScript, it doesn't work. The command is as follows:
@echo 1 | c:\SaveRestorePrinterSettings\RestorePrinterSettings.bat
This would input the value of 1 when a prompt comes up in the cmd prompt window. The 2nd batch file is designed to import some settings into a printer. Here is the 2nd batch file in it's entirety:
ECHO PRESS 1, 2 or 3 the printer to restore settings, or 4 to EXIT.
ECHO 1 - TIFF Image Printer 11.0
ECHO 2 - Raster Image Printer 11.0
ECHO 3 - PDF Image Printer 11.0
ECHO 4 - EXIT
SET /P M=Type 1, 2, 3 or 4 then press ENTER:
IF %M%==1 GOTO TIFF
IF %M%==2 GOTO RASTER
IF %M%==3 GOTO PDF
IF %M%==4 GOTO EOF
rundll32 printui.dll,PrintUIEntry /Sr /n "TIFF Image Printer 11.0" /a "tiffsettings.dat" u g
rundll32 printui.dll,PrintUIEntry /Sr /n "Raster Image Printer 11.0" /a "rastersettings.dat" u g
rundll32 printui.dll,PrintUIEntry /Sr /n "PDF Image Printer 11.0" /a "pdfsettings.dat" u g
I checked the PC that I was targeting with the script, and noticed that about half the time a windows error message came up if I ran the file from the script: " printers operation could not be completed 0x00004005 ". Again, this doesn't happen if I just double click the batch file. When I googled the error message one forum recommended running the print spooler first, so I tried adding a line for that several different ways. It always works if I run the file manually, but it just will not work via the KScript no matter what I try.
I think you are having sysnative problem. The Kace client is 32 bit and the OS is 64. The client is calling the DLL's in the Syswow64 instead of system32.
%windir%\Sysnative\rundll32 %windir%\Sysnative\printui.dll,PrintUIEntry /Sr /n "PDF Image Printer 11.0" /a "pdfsettings.dat" u g