+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
Windows Server 2008 R2 Thread, Printer vbs script, what have i done wrong... in Technical; Feel like i need a "geek" signal. lol Right, trying to get printers to work at hogwarts. Printers installed and ...
  1. #1

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,515
    Thank Post
    2,374
    Thanked 742 Times in 455 Posts
    Blog Entries
    2
    Rep Power
    541

    Printer vbs script, what have i done wrong...

    Feel like i need a "geek" signal. lol

    Right, trying to get printers to work at hogwarts. Printers installed and shared on Curricsvr2. I was convinced this worked the other day but the netbooks dont seem to want to pick up the printers on logon today.

    It's the bottom set im interested in.

    Code:
    on error resume next
    
    Set WshNetwork = CreateObject("WScript.Network")
    
    Dim Compname
    
    Compname = WSHNetwork.ComputerName
    
    	WshNetwork.RemovePrinterConnection "\\curricsvr1\STAFF-ROOM", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr1\TASROOM", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr1\LIBRARY", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr1\JUNIOR-SUITE", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr1\INFANT-SUITE", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr1\FOUNDATION", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr1\INFANT-OFFICE", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr2\STAFF", True, True
    	WshNetwork.RemovePrinterConnection "\\curricsvr2\STUDENT", True, True	
    
    if left(compname,8) = "JNRCLASS" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR_SUITE"
    	PrinterPath2 = "\\curricsvr1\INFANT_LIBRARY"
    	PrinterPath3 = "\\curricsvr1\MIDDLE_STOCK_ROOM"
    	PrinterPath4 = "\\curricsvr1\STAFF-ROOM"
    	
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.AddwindowsPrinterConnection PrinterPath4
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\INFANT_LIBRARY"
    
    end if 
    
    
    if left(compname,8) = "INFCLASS" then 
    
    	PrinterPath = "\\curricsvr1\INFANT_SUITE"
    	PrinterPath2 = "\\curricsvr1\INFANT_LIBRARY"
    	PrinterPath3 = "\\curricsvr1\FOUNDATION_STAGE"
    	PrinterPath4 = "\\curricsvr1\STAFF-ROOM"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.AddwindowsPrinterConnection PrinterPath4
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\INFANT_LIBRARY"
    
    end if
    
    if left(compname,4) = "JUNS" then 
    
    	PrinterPath = "\\curricsvr1\INFANT_SUITE"
    	PrinterPath2 = "\\curricsvr1\INFANT_LIBRARY"
    	PrinterPath3 = "\\curricsvr1\MIDDLE_STOCK_ROOM"
    	PrinterPath4 = "\\curricsvr1\STAFF-ROOM"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.AddwindowsPrinterConnection PrinterPath4
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\INFANT_SUITE"
    
    end if
    
    
    if left(compname,4) = "INFS" then 
    
    	PrinterPath = "\\curricsvr1\INFANT_SUITE"
    	PrinterPath2 = "\\curricsvr1\INFANT_LIBRARY"
    	PrinterPath3 = "\\curricsvr1\STAFF-ROOM"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\INFANT_SUITE"
    
    
    end if
    
    if left(compname,7) = "LIBRARY" then
    
    	PrinterPath =  "\\curricsvr1\INFANT_LIBRARY"
    	PrinterPath2 = "\\curricsvr1\JUNIOR_SUITE"
    	PrinterPath3 = "\\curricsvr1\INFANT_SUITE"
    	PrinterPath4 = "\\curricsvr1\STAFF-ROOM"
    	WshNetwork.AddwindowsPrinterConnection PrinterPath
    	WshNetwork.AddwindowsPrinterConnection PrinterPath2	
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.AddwindowsPrinterConnection PrinterPath4
    	wshNetwork.SetDefaultPrinter "\\curricsvr1\INFANT_LIBRARY"
    
    end if
    
    
    if left(compname,6) = "JNRSEN" then 
    
    	PrinterPath = "\\curricsvr1\MIDDLE_STOCK_ROOM"
    	PrinterPath2 = "\\curricsvr1\JUNIOR_SUITE"
    	PrinterPath3 = "\\curricsvr1\INFANT_LIBRARY"
    	PrinterPath4 = "\\curricsvr1\STAFF-ROOM"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.AddwindowsPrinterConnection PrinterPath4
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\MIDDLE_STOCK_ROOM"
    
    end if
    
    if left(compname,3) = "MSR" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR_SUITE"
    	PrinterPath2 = "\\curricsvr1\INFANT_LIBRARY"
    	PrinterPath3 = "\\curricsvr1\MIDDLE_STOCK_ROOM"
    	PrinterPath4 = "\\curricsvr1\STAFF-ROOM"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.AddwindowsPrinterConnection PrinterPath4
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\MIDDLE_STOCK_ROOM"
    
    end if
    
    if left(compname,7) = "NETBOOK" then 
    
    	PrinterPath = "\\curricsvr2\STUDENT"
    	PrinterPath2 = "\\curricsvr2\STAFF"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.SetDefaultPrinter "\\curricsvr2\STAFF"
    end if
    whats obvious that ive missed!? lol

    They seem to be defaulting to the "juns" one as well which is no good as they're not on this site!

    Help..

  2. #2

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,515
    Thank Post
    2,374
    Thanked 742 Times in 455 Posts
    Blog Entries
    2
    Rep Power
    541
    If there is a printer driver issue, would that cause this?

    The printers are installed quite happily on the server i can print from them...but if i manually add a printer i get told the drivers are incorrect....

    This is a 2K8 server and XP pro clients...

  3. #3

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,343
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414
    Dunno, but below is what I use to remove all connections rather than have to explicitly list them like you have.

    Code:
    'Remove ALL old printers
    'Enumerate all printers first, after that you can select the printers you want by performing some string checks
    Set WSHPrinters = WNet.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
          WNet.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
        End If
    'To remove all printers incuding LOCAL printers use this statement and comment out the If Statement above
    'WSHNetwork.RemovePrinterConnection WSHPrinters.Item(LOOP_COUNTER +1),True,True
    Next
    'end delete existing printers
    Which is helpfull if you add more printers in the future

    Ben

  4. #4

    Domino's Avatar
    Join Date
    Oct 2006
    Location
    Bromley
    Posts
    4,126
    Thank Post
    215
    Thanked 1,255 Times in 786 Posts
    Blog Entries
    4
    Rep Power
    505
    Have you added the 32bit drivers as well as the 64bit the server uses?

  5. #5

    plexer's Avatar
    Join Date
    Dec 2005
    Location
    Norfolk
    Posts
    13,343
    Thank Post
    624
    Thanked 1,584 Times in 1,421 Posts
    Rep Power
    414

  6. #6

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,710
    Thank Post
    3,246
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    If you want to use vbs to do this then I would defo put a pause in the script so that it gives the machine time to logon before trying to add printer connections etc. Not sure if it will help any but may be worth editing the below line :


    Compname = Trim(WSHNetwork.ComputerName)

    Also does Compname return the name as uppercase ?
    Last edited by mac_shinobi; 13th October 2011 at 01:33 PM.

  7. #7

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,515
    Thank Post
    2,374
    Thanked 742 Times in 455 Posts
    Blog Entries
    2
    Rep Power
    541
    Well that does make sense cus i havent. But these arent brand new printers, they are printers they used pre-fire just in new location so the clients should already have the drivers installed....or does it not work that way?

  8. #8

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,515
    Thank Post
    2,374
    Thanked 742 Times in 455 Posts
    Blog Entries
    2
    Rep Power
    541
    Ok, riddle me this.....it's only one of my netbook trolleys!! The other netbooks pick up the printers fine...

  9. #9

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,710
    Thank Post
    3,246
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    Quote Originally Posted by Little-Miss View Post
    Ok, riddle me this.....it's only one of my netbook trolleys!! The other netbooks pick up the printers fine...
    fair enough - in that case on the trolley of netbooks that are having issues - is this windows xp on them or what exactly ?

  10. #10

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,515
    Thank Post
    2,374
    Thanked 742 Times in 455 Posts
    Blog Entries
    2
    Rep Power
    541
    The same as other Netbooks. XP Pro, just a different model. NB300...the others are NB200.

  11. #11

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,783
    Thank Post
    1,623
    Thanked 1,877 Times in 1,395 Posts
    Blog Entries
    2
    Rep Power
    422
    Are there atheros cards in them?

  12. #12

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,515
    Thank Post
    2,374
    Thanked 742 Times in 455 Posts
    Blog Entries
    2
    Rep Power
    541
    I shall check but that rings a bell...

  13. #13

    mac_shinobi's Avatar
    Join Date
    Aug 2005
    Posts
    9,710
    Thank Post
    3,246
    Thanked 1,048 Times in 970 Posts
    Rep Power
    364
    They connecting wirelessly or hard wired ?

    Any errors in the event viewer in relation to printers or mapping the printers etc

  14. #14
    DAZZD88's Avatar
    Join Date
    Apr 2009
    Location
    Sunderland, Tyne and Wear
    Posts
    788
    Thank Post
    163
    Thanked 77 Times in 66 Posts
    Rep Power
    47
    @Plexer wouldn't this be easier and more readable? It's a portion of our printer script which is run using our logon.bat file.

    Code:
    'On Error Resume Next
    
    
    Call DelPrinterConnectionAll()
    
    Function DelPrinterConnectionAll()
    	
    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
    
    End Function

  15. #15

    nephilim's Avatar
    Join Date
    Nov 2008
    Location
    Dunstable
    Posts
    11,783
    Thank Post
    1,623
    Thanked 1,877 Times in 1,395 Posts
    Blog Entries
    2
    Rep Power
    422
    I can almost guarantee its the atheros cards. My old place had the same make and model, had all sorts of issues, managed to get Toshiba to supply us with intel wifi antennae for free and we replaced them ourselves (with letters attesting to the warranty not being voided) and the issues we had went away. I think Atheros wifi is absolute poo.

  16. Thanks to nephilim from:

    mac_shinobi (14th October 2011)

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. What have I done??
    By nickjelly in forum EduGeek Joomla 1.5 Package
    Replies: 3
    Last Post: 6th July 2011, 01:19 PM
  2. Have I done this right? - VB Script
    By Johan in forum Windows
    Replies: 4
    Last Post: 22nd September 2010, 03:30 PM
  3. What have you done with your Frog VLE?
    By Cue in forum Virtual Learning Platforms
    Replies: 2
    Last Post: 8th May 2009, 03:46 PM
  4. Replies: 19
    Last Post: 26th March 2009, 11:04 AM

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
  •