locked
batch file RRS feed

  • 問題

  • How to write the syntax to map the network printer automatically in batch file?

    2008年11月19日 下午 01:56

解答

  •  

    I think you may get problem to map a network printer to LPT.

     

     

    You can use follow command in bat file

    1. map printer

    rundll32 printui.dll,PrintUIEntry /in /q /n\\servername\printername

     

    2. delete network printer

    rundll32 printui.dll,PrintUIEntry /dn /q /n\\servename\printername

     

    3. Set the default printer
    rundll32 printui.dll,PrintUIEntry /y /n\\servername\printername

     

    *Note" the "PrintUIEntry" is case sensivity (P , U, I , E  must be big letter)

     

     

    another way is use VBScript.

    use notepad to create .vbs file and put code

     

    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
    objNetwork.SetDefaultPrinter \\PrintServer1\Xerox300 

     

    Informations From Microsoft Scripting Guy website

    http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan05/hey0113.mspx

     

    2008年11月20日 上午 03:47

所有回覆

  • You can try:

     

    NET USE [LPTx:] \\ComputerName\printer_share [/PERSISTENT:YES|NO]

    2008年11月19日 下午 02:05
  •  

    I think you may get problem to map a network printer to LPT.

     

     

    You can use follow command in bat file

    1. map printer

    rundll32 printui.dll,PrintUIEntry /in /q /n\\servername\printername

     

    2. delete network printer

    rundll32 printui.dll,PrintUIEntry /dn /q /n\\servename\printername

     

    3. Set the default printer
    rundll32 printui.dll,PrintUIEntry /y /n\\servername\printername

     

    *Note" the "PrintUIEntry" is case sensivity (P , U, I , E  must be big letter)

     

     

    another way is use VBScript.

    use notepad to create .vbs file and put code

     

    Set objNetwork = CreateObject("WScript.Network")
    objNetwork.AddWindowsPrinterConnection "\\PrintServer1\Xerox300"
    objNetwork.SetDefaultPrinter \\PrintServer1\Xerox300 

     

    Informations From Microsoft Scripting Guy website

    http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan05/hey0113.mspx

     

    2008年11月20日 上午 03:47
  • Dear Customer,

    I agree with Raymond Yuen and ComBilLi ’s suggestion.

     

    If there is anything unclear, please feel free to contact me.


    Sincerely


    Tom Zhang

     

    2008年11月20日 上午 09:22
    版主