/build/static/layout/Breadcrumb_cap_w.png

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 OFF

SET PATH=C:\Windows\SysWow64;%PATH%

CLS

:MENU

ECHO.

ECHO ...............................................

ECHO PRESS 1, 2 or 3 the printer to restore settings, or 4 to EXIT.

ECHO ...............................................

ECHO.

ECHO 1 - TIFF Image Printer 11.0

ECHO 2 - Raster Image Printer 11.0

ECHO 3 - PDF Image Printer 11.0

ECHO 4 - EXIT

ECHO.

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

GOTO MENU


:TIFF

rundll32 printui.dll,PrintUIEntry /Sr /n "TIFF Image Printer 11.0" /a "tiffsettings.dat" u g

GOTO EOF


:RASTER

rundll32 printui.dll,PrintUIEntry /Sr /n "Raster Image Printer 11.0" /a "rastersettings.dat" u g

GOTO EOF


:PDF

rundll32 printui.dll,PrintUIEntry /Sr /n "PDF Image Printer 11.0" /a "pdfsettings.dat" u g

GOTO EOF



:EOF


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.


2 Comments   [ + ] Show comments
  • how are you running the script as? - SMal.tmcc 5 years ago
  • I've tried running it as Domain Admin, Local System, Logged in user, it will not work via Kace. I can run the batch file manually with no issues.

    I think it has something to do with the fact that I'm trying to change printer settings. The first half of my script runs some mkdir and xcopy commands and I have no problem with that, so I know that Kace is working.

    It's when I get to the 2nd half where I'm trying to preset the input value, and update the printer preferences, that I hit a dead end. Either nothing happens, or I get the error I mentioned in my original post. - SMandelos 5 years ago
    • I bet these are 64bit OS's you are having the problem with - SMal.tmcc 5 years ago

Answers (1)

Posted by: SMal.tmcc 5 years ago
Red Belt
0

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.


https://www.google.com/search?client=firefox-b-1-d&q=%25sysnative%25

try

%windir%\Sysnative\rundll32 %windir%\Sysnative\printui.dll,PrintUIEntry /Sr /n "PDF Image Printer 11.0" /a "pdfsettings.dat" u g

Comments:
  • I received the following error:

    there was a problem starting c:\windows\sysnative\printui.dll the specified module could not be found - SMandelos 5 years ago
    • try just the hard paths then for the calls (C:\Windows\System32\rundll32 C:\Windows\System32\printui.dll,PrintUIEntry /Sr /n "PDF Image Printer 11.0" /a "pdfsettings.dat" u g) - SMal.tmcc 5 years ago
      • I've tried doing this several different ways ( Batch file embedded in the script itself, ran a separate batch file from the script, even removed all the additional unnecessary commands etc and just tried running the one line for the import ), and now nothing happens at all, no error message and no change to the printer. I even tried re-booting and I'm still not seeing anything happen. - SMandelos 5 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ