none
remove network printer mappings RRS feed

  • Question

  • im trying to use the following script in the logoff script to remove the network printer mapping from the client PCs..

    RUNDLL32 printui.dll,PrintUIEntry /n \\server name /dn

    But it returns with an error "printer connection cannot be removed.Operation could not be completed (error 0X00000057)..Is there something wrong with the script????

    RUNDLL32 printui.dll,PrintUIEntry /n \\server-name\printer-name /dn ..This script works to remove individual printers..but i want to remove multiple printers without specifying the printer names..

    Thanks in advance...

    • Edited by San_dy Tuesday, March 27, 2012 11:41 AM
    Tuesday, March 27, 2012 8:11 AM

Answers

  • Hi,

    Regarding the command line which you mentioned, you may refer to the following article:

    Rundll32 printui.dll,PrintUIEntry

    Also, there is a script in the following link for your reference:

    Contents of Guy's Scripting Ezine No 16a: RUNDLL32 PRINTUI.DLL,PrintUIEntry  - Printer Scripts

    Please Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

    A this issue is related with logoff script, in order to get the answer effectively, it is recommended to post a new question in the Script Forum for further discussion.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Hope this help.

    Best Regards,

    Tracy Cai


    Wednesday, March 28, 2012 9:14 AM
    Moderator
  • Hello

    On my point of view you have a problem in your scenario.

    because your users quit their offices, logically they are choosing to shutdown their laptop and aren't logging off.

    So in this case any solutions to remove network printers are failed, because during the shutdown process, Spooler service is stopping.

    Could you explain why you want to "hide" ("remove") the network printers durin out-of-office period ?

    is it a "cosmetic" demand to end-user or other aspects ?

    Regards


    Eric 

    Wednesday, March 28, 2012 3:01 PM

All replies

  • Hello

    Try this VBS, It works

    =======================================

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set Printers = WshNetwork.EnumPrinterConnections

    For i = 0 to Printers.Count - 1 Step 2

    If Left(ucase(Printers.Item(i+1)),2) = "\\" Then
    WScript.Echo Printers.Item(i+1)
    WSHNetwork.RemovePrinterConnection Printers.Item(i+1)
    End IF
    Next

    =======================================

    Regards


    Eric


    Tuesday, March 27, 2012 8:42 AM
  • Hi

    i tried the vbs..it doesnt seem to remove the printer mappings..The printers were mapped using printer management console..and i added the vbs you gave to the logoff script..but doesnt seem to work :(


    Sumy Sebastian

    Tuesday, March 27, 2012 10:05 AM
  • Hi,

    Regarding the command line which you mentioned, you may refer to the following article:

    Rundll32 printui.dll,PrintUIEntry

    Also, there is a script in the following link for your reference:

    Contents of Guy's Scripting Ezine No 16a: RUNDLL32 PRINTUI.DLL,PrintUIEntry  - Printer Scripts

    Please Note: Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

    A this issue is related with logoff script, in order to get the answer effectively, it is recommended to post a new question in the Script Forum for further discussion.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    Hope this help.

    Best Regards,

    Tracy Cai


    Wednesday, March 28, 2012 9:14 AM
    Moderator
  • Hello

    The user account has has admin privileges and i don't want to use it on logon script as what I want is , once the user logs off and takes his laptop home or is away from the domain ,he shouldn't see the network printers.

    The OS on client system is windows 7 professional.

    Regards,



    Sumy Sebastian

    Wednesday, March 28, 2012 2:41 PM
  • Hello

    On my point of view you have a problem in your scenario.

    because your users quit their offices, logically they are choosing to shutdown their laptop and aren't logging off.

    So in this case any solutions to remove network printers are failed, because during the shutdown process, Spooler service is stopping.

    Could you explain why you want to "hide" ("remove") the network printers durin out-of-office period ?

    is it a "cosmetic" demand to end-user or other aspects ?

    Regards


    Eric 

    Wednesday, March 28, 2012 3:01 PM
  • Hi Eric,

    This script work perfectly, but how can I stop users from seeing it at logoff.

    Thanks

    kpasasa

    Friday, April 12, 2013 11:01 AM