none
Script for adding network printer for all users - with user input RRS feed

  • Question

  • Hello - I am trying to create a script which allows user input to add network printers for all users. This is what I have so far but am unable to figure out how to finish. Any help is greatly appreciated Thanks!

    @echo off
    set Output="c:\"
    
    set /p VarOne=Enter Computer Name: 
    set /p VarTwo=Enter Print Server: 
    set /p VarThree=Enter Printer Name: 
    
    
    REM enter your desired output here
    echo=%VarOne% >> %Output%\test.txt
    echo=%VarTwo% >> %Output%\test.txt
    echo=%VarThree% >> %Output%\test.txt
    
    
    echo.
    echo File has been placed %Output%
    pause
    
    rundll32 printui.dll,PrintUIEntry /ga /c\\%1 /n\\%2
    start /wait sc \\%1 stop spooler
    start /wait sc \\%1 start spooler
    
    
    


    • Edited by Tuco72 Friday, October 17, 2014 4:11 PM
    Friday, October 17, 2014 4:08 PM

Answers

All replies

  • The usual means of doing this is not with a script but rather to assign network printers using a GPO.


    -- Bill Stewart [Bill_Stewart]

    Friday, October 17, 2014 4:11 PM
    Moderator
  • Valid point however GPO is not an option for me without a lot of red tape and hassle. 
    Friday, October 17, 2014 4:16 PM
  • The technique you are trying to use to add per-machine printers is deprecated. Trying to script your way around company policies is not recommended and will likely be problematic in the long run.

    -- Bill Stewart [Bill_Stewart]

    Friday, October 17, 2014 4:21 PM
    Moderator
  • Sorry - wrong thread,




    • Edited by jrv Friday, October 17, 2014 7:24 PM
    Friday, October 17, 2014 7:07 PM
  • (jrv: I think you are replying to the wrong thread)

    -- Bill Stewart [Bill_Stewart]

    Friday, October 17, 2014 7:14 PM
    Moderator
  • I would just create a link to the add printer dialog as it does all of the things you are doing in your script.  Why rewrite Windows.


    ¯\_(ツ)_/¯

    Friday, October 17, 2014 7:30 PM
  • Sorry -wrong dialog.



    ¯\_(ツ)_/¯




    • Edited by jrv Friday, October 17, 2014 7:45 PM
    Friday, October 17, 2014 7:43 PM
  • Hah! I almost forgot how to do it.

    # show rpinter dialog and allow user to select printer.
    Add-Type -AssemblyName System.Windows.Forms
    $dlg=New-Object System.Windows.Forms.PrintDialog
    $dlg.UseEXDialog=$true
    $dlg.ShowDialog()
    
    

    This shows the full Add a network printer and it respects NLA so set your printer locations and the closest printer will be listed.

    For NLA post In GP forum for help on configuring NLA on the domain.


    ¯\_(ツ)_/¯

    Friday, October 17, 2014 8:01 PM