none
Script to install printer, help! RRS feed

  • Question

  • My company does not use Active Directory. We just put a new printer in, and I want to install the printer by deploying a script through Novell. I have the script pretty much all ready to go, except it has one problem... it makes the printer default on my machine every time I run it. I was wondering if someone could take a look at it and see what I need to do to remove the action of making the printer default.

    Here is the script:

    CLS
    @ECHO off
     
    SET varIP=172.16.20.7
    SET varDriver=Xerox WorkCentre 7535 PS
    SET varDriverFolder=C:\Xerox\WC7545-7556_PS_x64_Driver.inf
    SET varDriverFile=C:\Xerox\WC7545-7556_PS_x64_Driver.inf\x2DNORP.inf
    SET varName=Mailroom Xerox 7535
    SET varLocation=Mailroom
     
    REM "Deleting TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -d -r IP_%varIP%
     
    REM "Creating TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_%varIP% -o raw -n 9100 -h %varIP%
     
    CLS
    REM "Installation message"
    @ECHO.
    @ECHO The %varLocation% printer is currently being installed.
    @ECHO.
    @ECHO Please do not close this window.
    @ECHO.
    @ECHO Once the installation is complete this Setup window will exit.
    @ECHO.
     
    REM "Driver installation"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prndrvr.vbs -a -m "%varDriver%" -h "%varDriverFolder%" -i "%varDriverFile%"  
    CLS
     
    REM "Printer deletion"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -d -p "%varName%"
    CLS
     
    REM "Printer installation"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -a -p "%varName%" -m "%varDriver%" -r "IP_%varIP%"
    CLS
     
    REM "Location configuration"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prncnfg.vbs -p "%varName%" -l "%varLocation%"
    CLS

    This is a Windows 7 Pro environment.

    Friday, September 26, 2014 1:46 PM

Answers

  • Ok so through some research I altered the script to do what I want. Here it is for anyone that needs it.

    CLS
    @ECHO off
    
    SET varIP=172.16.20.7
    SET varDriver=Xerox WorkCentre 7535 PS
    SET varDriverFolder=C:\Xerox\WC7545-7556_PS_x64_Driver.inf
    SET varDriverFile=C:\Xerox\WC7545-7556_PS_x64_Driver.inf\x2DNORP.inf
    SET varName=Xerox 7535
    SET varLocation=Mailroom
    
    REM "Get default printer and store in variable"
    for /f "tokens=4*" %%i in ('cscript /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g ^|find "default printer"') do set ydp=%%j
    echo %ydp%
    
    REM "Deleting TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -d -r IP_%varIP%
    
    REM "Creating TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_%varIP% -o raw -n 9100 -h %varIP%
    
    CLS
    REM "Installation message"
    @ECHO.
    @ECHO The %varLocation% printer is currently being installed.
    @ECHO.
    @ECHO Please do not close this window.
    @ECHO.
    @ECHO Once the installation is complete this Setup window will exit.
    @ECHO.
    
    REM "Driver installation"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prndrvr.vbs -a -m "%varDriver%" -h "%varDriverFolder%" -i "%varDriverFile%"  
    CLS
    
    REM "Printer installation"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -a -p "%varName%" -m "%varDriver%" -r "IP_%varIP%"
    CLS
    
    REM "Location configuration"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prncnfg.vbs -t -p "%varName%" -l "%varLocation%"
    CLS
    
    REM "Set printer to old default"
    @ECHO.
    @ECHO Setting original printer to default
    echo %ydp%
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -t -p "%ydp%"
    Thanks for the help guys!

    • Marked as answer by fishar Friday, September 26, 2014 3:47 PM
    Friday, September 26, 2014 3:47 PM

All replies

  • Run this and follow the instructions:

    cscript %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs


    ¯\_(ツ)_/¯

    Friday, September 26, 2014 1:52 PM
  • OK... I am aware of the arguments. But since I do not use "-t" anywhere in the script, why is it still setting the new printer as default. Are you suggesting I should add a section to set the default printer to the original? How could this be possible if the printer name is not consistent among all our machines as they were added individually. I don't want to do that anyways because not all of our users print to the same printer.
    • Edited by fishar Friday, September 26, 2014 2:07 PM
    Friday, September 26, 2014 2:01 PM
  • Because you are deleting the default printer.  Set the printer you want as default before deleting the printer.


    ¯\_(ツ)_/¯

    Friday, September 26, 2014 2:09 PM
  • OK I removed the deletion section and it still makes it the default printer. I can't set a default printer with the script because we have users that print to different printers. If I do that then I will still have to go to everyone's machine and manually change it back to their printer. 

    CLS
    @ECHO off
    
    SET varIP=172.16.20.7
    SET varDriver=Xerox WorkCentre 7535 PS
    SET varDriverFolder=C:\Xerox\WC7545-7556_PS_x64_Driver.inf
    SET varDriverFile=C:\Xerox\WC7545-7556_PS_x64_Driver.inf\x2DNORP.inf
    SET varName=Mailroom Xerox 7535
    SET varLocation=Mailroom
    
    REM "Deleting TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -d -r IP_%varIP%
    
    REM "Creating TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_%varIP% -o raw -n 9100 -h %varIP%
    
    CLS
    REM "Installation message"
    @ECHO.
    @ECHO The %varLocation% printer is currently being installed.
    @ECHO.
    @ECHO Please do not close this window.
    @ECHO.
    @ECHO Once the installation is complete this Setup window will exit.
    @ECHO.
    
    REM "Driver installation"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prndrvr.vbs -a -m "%varDriver%" -h "%varDriverFolder%" -i "%varDriverFile%"  
    CLS
    
    REM "Printer installation"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -a -p "%varName%" -m "%varDriver%" -r "IP_%varIP%"
    CLS
    
    REM "Location configuration"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prncnfg.vbs -p "%varName%" -l "%varLocation%"
    CLS


    • Edited by fishar Friday, September 26, 2014 2:16 PM
    Friday, September 26, 2014 2:16 PM
  • Use the scrip to retrieve the current default printer and save it then reset when done.


    ¯\_(ツ)_/¯

    Friday, September 26, 2014 2:19 PM
  • You wouldn't have any idea how to store just the printer name from the output of
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g
    to a variable, would you?
    Friday, September 26, 2014 2:31 PM
  • Start with:

    HELP FOR


    ¯\_(ツ)_/¯

    Friday, September 26, 2014 2:36 PM
  • Haha I knew it wasn't going to be that easy. Thanks for the help man.
    Friday, September 26, 2014 2:42 PM
  • Make it easier on yourself. Set up a print server, share the printers, and connect them via GPO.


    -- Bill Stewart [Bill_Stewart]

    Friday, September 26, 2014 2:46 PM
    Moderator
  • Believe me, I thought of that... but I don't know how I feel about leaving it unauthenticated.
    Friday, September 26, 2014 3:00 PM
  • Leaving what authenticated? Shared printers can have permissions set on them just like other objects.


    -- Bill Stewart [Bill_Stewart]

    Friday, September 26, 2014 3:03 PM
    Moderator
  • I just noticed you're talking about Novell.

    You should ask in a more appropriate forum about the correct way of deploying printers in that environment.

    Installing TCP/IP printers separately on machines is a management headache.

    Before you ask: No, I don't know where you would ask about that. (But for sure, this isn't the right place to ask Novell questions.)


    -- Bill Stewart [Bill_Stewart]

    Friday, September 26, 2014 3:06 PM
    Moderator
  • Before you ask: No, I don't know where you would ask about that. (But for sure, this isn't the right place to ask Novell questions.)

    This might be a good spot to start:

    http://forums.novell.com/forum.php

    I have no personal experience with these forums, so I have no idea what the quality level is there.


    Don't retire TechNet! - (Don't give up yet - 13,085+ strong and growing)

    Friday, September 26, 2014 3:12 PM
  • The correct way of deploying printers with Novell is more of a headache than installing them separately
    Friday, September 26, 2014 3:44 PM
  • Ok so through some research I altered the script to do what I want. Here it is for anyone that needs it.

    CLS
    @ECHO off
    
    SET varIP=172.16.20.7
    SET varDriver=Xerox WorkCentre 7535 PS
    SET varDriverFolder=C:\Xerox\WC7545-7556_PS_x64_Driver.inf
    SET varDriverFile=C:\Xerox\WC7545-7556_PS_x64_Driver.inf\x2DNORP.inf
    SET varName=Xerox 7535
    SET varLocation=Mailroom
    
    REM "Get default printer and store in variable"
    for /f "tokens=4*" %%i in ('cscript /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -g ^|find "default printer"') do set ydp=%%j
    echo %ydp%
    
    REM "Deleting TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -d -r IP_%varIP%
    
    REM "Creating TCP/IP port"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnport.vbs -a -r IP_%varIP% -o raw -n 9100 -h %varIP%
    
    CLS
    REM "Installation message"
    @ECHO.
    @ECHO The %varLocation% printer is currently being installed.
    @ECHO.
    @ECHO Please do not close this window.
    @ECHO.
    @ECHO Once the installation is complete this Setup window will exit.
    @ECHO.
    
    REM "Driver installation"
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prndrvr.vbs -a -m "%varDriver%" -h "%varDriverFolder%" -i "%varDriverFile%"  
    CLS
    
    REM "Printer installation"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -a -p "%varName%" -m "%varDriver%" -r "IP_%varIP%"
    CLS
    
    REM "Location configuration"
    @ECHO.
    @ECHO Completing installation.
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prncnfg.vbs -t -p "%varName%" -l "%varLocation%"
    CLS
    
    REM "Set printer to old default"
    @ECHO.
    @ECHO Setting original printer to default
    echo %ydp%
    CSCRIPT /nologo %windir%\system32\Printing_Admin_Scripts\en-US\prnmngr.vbs -t -p "%ydp%"
    Thanks for the help guys!

    • Marked as answer by fishar Friday, September 26, 2014 3:47 PM
    Friday, September 26, 2014 3:47 PM
  • The correct way of deploying printers with Novell is more of a headache than installing them separately

    As a Novell CNE I can tell you that Novell is obsolete just like Vines.


    ¯\_(ツ)_/¯

    Friday, September 26, 2014 3:52 PM