+ Post New Thread
Results 1 to 13 of 13
Windows Server 2008 Thread, Server 2008 Deployment of Network Printers in Technical; Hi there, I am currently experiencing some problems at a school I have been supporting. The school currently have 4 ...
  1. #1

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10

    Question Server 2008 Deployment of Network Printers

    Hi there, I am currently experiencing some problems at a school I have been supporting. The school currently have 4 networked printers which are shared out to all users via the Active Directory Logon script.
    The script looks like this:

    Code:
    @Echo Off
    
    Net Use YXC
    
    \\servername\netlogon\con2prt.exe /c \\servername\Printer1
    \\servername\netlogon\con2prt.exe /c \\servername\Printer2
    \\servername\netlogon\con2prt.exe /c \\servername\Printer3
    \\servername\netlogon\con2prt.exe /c \\servername\Printer4
    The script appears to have worked well, however, I am finding that when I log on to a random system as any user, there are about 10 printers. They seem to be old networked printers which no longer exist. The fact these are showing on normal user network accounts is strange. I can't see anything in the group policy. THis really needs tidying up as people keep sending jobs to the non existant printers. Can anyone suggest ways I can solve this mess?

  2. #2

    Join Date
    Aug 2011
    Location
    Ellesmere Port
    Posts
    20
    Thank Post
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    7
    We use a vbs to map them, and before mapping them we put:

    Set WSHPrinters = WSHNetwork.EnumPrinterConnections
    For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
    'To remove only networked printers use this If Statement
    If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
    WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
    End If

    This clears off the existing network printers before connecting the new ones.

  3. Thanks to EPCHS from:

    talksr (30th July 2013)

  4. #3

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    Hi there, thanks for your post.
    I have never mapped them via VBS before. Would you just point the script path on Active Directory to the vbs file in the NetLogon Folder?

    I don't suppose you could show me an example of your script with a network printer included and I will give it a go here?
    Thanks for the removal part of the vbs script, very useful.

  5. #4
    AJWhite1970's Avatar
    Join Date
    Sep 2012
    Location
    Wiltshire
    Posts
    341
    Thank Post
    92
    Thanked 76 Times in 58 Posts
    Rep Power
    17
    On Error resume Next
    set objNetwork = WScript.CreateObject("WScript.Network")
    set objShell = WScript.CreateObject("WScript.Shell")

    'Add Network printers
    objNetwork.AddWindowsPrinterConnection "\\quartz\HP Colour LaserJet CP2025n ART01"

    'Set Default Printer
    objNetwork.SetDefaultPrinter "\\quartz\HP Colour LaserJet CP2025n ART01"

  6. Thanks to AJWhite1970 from:

    talksr (30th July 2013)

  7. #5

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    Hi there, here is what I have knocked up based on your helpful posts:
    Code:
    Set WSHPrinters = WSHNetwork.EnumPrinterConnections
    For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
    'To remove only networked printers use this If Statement
    If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
    WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
    End If
    On Error resume Next
    set objNetwork = WScript.CreateObject("WScript.Network")
    set objShell = WScript.CreateObject("WScript.Shell")
    
    'Add Network printers
    objNetwork.AddWindowsPrinterConnection "\\smcessvr\ICT-SUITE"
    
    'Set Default Printer
    objNetwork.SetDefaultPrinter "\\smcessvr\ICT-SUITE"
    WScript.quit
    It is telling me the following when it runs:
    Expected 'Next' on Line 17, char 1.
    Line 17 would be the blank line after WScript.quit.

    What am I missing here?

  8. #6
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,013
    Thank Post
    120
    Thanked 283 Times in 261 Posts
    Rep Power
    108
    You have started a for loop

    Code:
    For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
    But you haven't defined an end to it. Try this

    Code:
    Set WSHPrinters = WSHNetwork.EnumPrinterConnections
    For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
    'To remove only networked printers use this If Statement
    If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
    WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
    End If
    next
    On Error resume Next
    set objNetwork = WScript.CreateObject("WScript.Network")
    set objShell = WScript.CreateObject("WScript.Shell")
    
    'Add Network printers
    objNetwork.AddWindowsPrinterConnection "\\smcessvr\ICT-SUITE"
    
    'Set Default Printer
    objNetwork.SetDefaultPrinter "\\smcessvr\ICT-SUITE"
    WScript.quit

  9. Thanks to ChrisH from:

    talksr (30th July 2013)

  10. #7

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    Quote Originally Posted by ChrisH View Post
    You have started a for loop

    Code:
    For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
    But you haven't defined an end to it. Try this

    Code:
    Set WSHPrinters = WSHNetwork.EnumPrinterConnections
    For LOOP_COUNTER = 0 To WSHPrinters.Count - 1 Step 2
    'To remove only networked printers use this If Statement
    If Left(WSHPrinters.Item(LOOP_COUNTER +1),2) = "\\" Then
    WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
    End If
    next
    On Error resume Next
    set objNetwork = WScript.CreateObject("WScript.Network")
    set objShell = WScript.CreateObject("WScript.Shell")
    
    'Add Network printers
    objNetwork.AddWindowsPrinterConnection "\\smcessvr\ICT-SUITE"
    
    'Set Default Printer
    objNetwork.SetDefaultPrinter "\\smcessvr\ICT-SUITE"
    WScript.quit
    Hi there. Thanks for your help. I have not had to look at Visual Basic for quite some time, and even when I have, it has just been tweaking stuff others have already done. Maybe I should get on a course.
    I have tried your updated version, it now says that on line one, Object required: 'WSHNetwork'.
    I can see it uses WSHNetwork, so im assuming I need to declare it somewhere?

  11. #8
    AJWhite1970's Avatar
    Join Date
    Sep 2012
    Location
    Wiltshire
    Posts
    341
    Thank Post
    92
    Thanked 76 Times in 58 Posts
    Rep Power
    17
    Alternate printer delete script:-

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Network = True")

    For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
    Next

  12. #9

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    Quote Originally Posted by AJWhite1970 View Post
    Alternate printer delete script:-

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Network = True")

    For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
    Next
    Hi there, that script worked very well and without any errors. I am thinking of adding that VBS to the existing netlogon bat file.
    At the moment, when I reference the VBS script, the computer is trying to look in C:\ of the local machine rather than netlogon. How can I overcome this?
    The cmd error shown is:

    Code:
    Input Error: Can not find script file "C:\Windows\remprinters.vbs".
    Press any key to continue . . .
    The batch script is as follows:
    Code:
    @ECHO OFF
    
    cscript.exe remprinters.vbs
    
    pause 10
    
    NET USE I: \\smcessvr\APPLIC /PERSISTENT:NO
    NET USE O: \\smcessvr\SHARED /PERSISTENT:NO
    NET USE T: \\smcessvr\STAFFSHARED /PERSISTENT:NO
    NET use u: \\smcessvr\ClassHome /persistent:no
    
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\Staffworkroom
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\ICT-Suite
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\StaffRMPrinter
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\Reception-Building
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\StaffRMCopier

  13. #10
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,013
    Thank Post
    120
    Thanked 283 Times in 261 Posts
    Rep Power
    108
    Quote Originally Posted by talksr View Post
    Hi there. Thanks for your help. I have not had to look at Visual Basic for quite some time, and even when I have, it has just been tweaking stuff others have already done. Maybe I should get on a course.
    I have tried your updated version, it now says that on line one, Object required: 'WSHNetwork'.
    I can see it uses WSHNetwork, so im assuming I need to declare it somewhere?
    You need to move your declarations to the top

    Code:
    set objNetwork = WScript.CreateObject("WScript.Network")
    set objShell = WScript.CreateObject("WScript.Shell")

  14. #11

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    Hi there. Thanks for all of your help. This is what I have so far. It is working really well on Windows XP and 7 systems. But I am getting a Generic failure on line 9 of the vbs script when ran on a Windows 8 system.

    Here is my batch file:
    Code:
    @ECHO OFF
    REM The following lines run my VBS script to remove all printers on computer. H: is mapped to run the script from NetLogon
    NET USE H: \\smcessvr\NETLOGON
    wscript "H:\remprinters.vbs"
    
    pause 5
    
    REM End of Printer Removal Script NETUSE H: is removed on last line below: 
    
    NET USE I: \\smcessvr\APPLIC /PERSISTENT:NO
    NET USE O: \\smcessvr\SHARED /PERSISTENT:NO
    NET USE T: \\smcessvr\STAFFSHARED /PERSISTENT:NO
    NET use U: \\smcessvr\ClassHome /PERSISTENT:NO
    net use H: /delete /Y
    
    REM Printers are added below:
    
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\Staffworkroom
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\ICT-Suite
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\StaffRMPrinter
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\Reception-Building
    \\smcessvr\netlogon\con2prt.exe /c \\smcessvr\StaffRMCopier
    And this is my VBS file with help from you guys:
    Code:
    strComputer = "."
    
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    
    Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Network = True")
    
    For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
    Next

  15. #12

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    Hi, I am currently running the following vbs script on Logon, but I am getting an error:

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set colInstalledPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Network = True")

    For Each objPrinter in colInstalledPrinters
    objPrinter.Delete_
    Next

    The error is as follows:

    Permission denied 'GetObject'
    Code: 800A0046

    The line in question is:
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")


    I am logging in as a pupil. Could it be that they don't have the right access levels to run this vbs script?
    Any help would be great!
    Last edited by talksr; 10th October 2013 at 03:39 PM.

  16. #13

    Join Date
    Feb 2010
    Location
    UK
    Posts
    275
    Thank Post
    183
    Thanked 4 Times in 4 Posts
    Rep Power
    10
    *BUMP*

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 1
    Last Post: 4th February 2013, 10:10 PM
  2. Network Printer Server 2008 R2
    By spik376 in forum Windows Server 2008 R2
    Replies: 17
    Last Post: 28th January 2013, 12:14 PM
  3. Replies: 2
    Last Post: 2nd September 2010, 05:10 PM
  4. Replies: 7
    Last Post: 28th July 2010, 12:12 PM
  5. Deployment of printers without 2008 dc
    By Cache in forum Windows Server 2008
    Replies: 0
    Last Post: 26th June 2009, 07:25 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •