I am having trouble getting the script below to run on 32-bit XP and 2003 systems when pushed from the K1000. However, if I run it from a batch file saved to c:\ it runs with no issues. The printer port gets created and the print spooler restarts, but the command prompt windows doesn't popup and rundll32 does not run. On the Win7 64-bit machines I have tested it on, it runs with no issues and the cmd windows appears and displays the proper echo messages when pushed from the K1000. I tried changing it from offline kscript to online kscript. As an online script I have tried it using both local system and run as using domain admin credentials.

I am using the most recent version for the K1000 and agent.

Any help would be greatly appreciated. Thanks

@echo off
echo The printer drivers are installing. This window will close when complete. Do NOT close manually or install will not complete.
echo ---------
echo Creating printer port
IF EXIST "C:\Windows\System32\Printing_Admin_Scripts\en-US" GOTO :Win7
cscript %windir%\system32\prnport.vbs -a -r IP_10.10.1.6 -h 10.10.1.6 -o raw -n 9100
GOTO :Install
:Win7
cscript %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_10.10.1.6 -h 10.10.1.6 -o raw -n 9100
:Install

echo Restarting Print Spooler
net stop spooler && net start spooler

if "%programfiles(x86)%"=="%programfiles(x86)%" goto 32BIT
echo Installing 64-bit drivers
rundll32 printui.dll,PrintUIEntry /if /b "SK01 Copier" /f "\\skmgmthou\software\Printer Drivers\Canon iR3245\UFRII\64-bit\CNLB0UA64.INF" /r "IP_10.10.1.6" /m "Canon iR3235/iR3245 UFR II" /z

goto END

:32BIT
echo Installing 32-bit drivers
rundll32 %windir%\system32\printui.dll,PrintUIEntry /if /b "SK01 Copier" /f "\\skmgmthou\software\Printer Drivers\Canon iR3245\UFRII\32-bit\CNLB0U.INF" /r "IP_10.10.1.6" /m "Canon iR3235/iR3245 UFR II" /z

:END
exit
Answer Summary:
I found a solution...since the file runs locally, I attached the the .bat file as a dependency and then use launch a program to run it from the dependency folder on the pc. This allows it to run successfully on XP, 2003, and 7, either x86 or x64. I gave pjgeutjens and Tentacle Master credit for helping with the answer since they both helped me to correct the scripting.
Cancel
1 Comment   [ + ] Show Comment

Comments

  • I have modifed the script. I am deploying this on a workgroup system running Windows 7 64-bit. It errors out at Installing 64-bit drivers...
Please log in to comment

Community Chosen Answer

4
pjgeutjens is correct,

your use of GOTO commands are incorrect. it should be GOTO Win7 not GOTO :Win7.

Also,
if "%programfiles(x86)%"=="%programfiles(x86)%" goto 32BIT is an incorrect method to check for architecture, it will always be true.

Instead use IF "%PROCESSOR_ARCHITECTURE%"=="x86" GOTO 32BIT
Answered 03/26/2012 by: Tentacle Master
Fourth Degree Black Belt

  • Thanks for architecture variable, I couldn't find it. My original script had the line read if "%programfiles(x86)%XXX"=="XXX" goto 32BIT, but I changed it to what you said. I also corrected GOTO commands. However, it still stops running after the services are restarted and works fine if ran locally instead of being pushed.
Please log in to comment

Answers

2
2 remarks:

I dunno if you copy/pasted the script, but your use of GOTO is inconsistent. You sometimes use the colon in the goto command, which I don't think is the way it should be.
So not GOTO :Win7 but GOTO Win7

Second, I'm pretty sure your condition if "%programfiles(x86)%"=="%programfiles(x86)%" is not as it should be... this will always evaluate true if I'm not mistaken. I think it should be if "%programfiles(x86)%"==""

PJ
Answered 03/26/2012 by: pjgeutjens
Red Belt

Please log in to comment
1
I found a solution...since the file runs locally, I attached the the .bat file as a dependency and then use launch a program to run it from the dependency folder on the pc. This allows it to run successfully on XP, 2003, and 7, either x86 or x64. I gave pjgeutjens and Tentacle Master credit for helping with the answer since they both helped me to correct the scripting.
Answered 03/28/2012 by: jcantello
White Belt

Please log in to comment
0
I haven't used this in a while, but it worked on both Windows 7 and XP (both 32-bit), with the 5.0 and 5.1 KBOX agents. I copied this line from the raw XML editor:



Sande
Answered 03/29/2012 by: snissen
Fourth Degree Green Belt

  • Well, shoot, the line won't paste unless I remove some delimiters:

    launch_program path="$(KBOX_SYS_DIR)" program="cscript.exe" wait="true" parms="//B //Nologo //T:30 "$(KACE_DEPENDENCY_DIR)\prnport.vbs" -a -r IP_137.22.251.251 -h 137.22.251.251 -o raw -n 9100"
Please log in to comment
-1
What about run as user logged in? I have a similiar script that only works as logged in user.
Answered 03/26/2012 by: dugullett
Red Belt

  • Did not change anything. Thanks
Please log in to comment
Answer this question or Comment on this question for clarity