Poll: Was this script helpful?

Be advised that this is a public poll: other users can see the choice(s) you selected.

+ Post New Thread
Page 3 of 11 FirstFirst 1234567 ... LastLast
Results 31 to 45 of 165
Scripts Thread, A Printer Script in Coding and Web Development; This reminds me of a problem I had where if you had manually installed the printer (ie unscripted) the script ...
  1. #31
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,987
    Thank Post
    120
    Thanked 283 Times in 261 Posts
    Rep Power
    107

    Re: A Printer Script

    This reminds me of a problem I had where if you had manually installed the printer (ie unscripted) the script would not delete the printer. Its something to do with the i+1 . I shall see if I can find my old post on another forum to see if it is relevant.

  2. #32
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    3,035
    Thank Post
    305
    Thanked 293 Times in 203 Posts
    Rep Power
    120

    Re: A Printer Script

    ive got full permissions on this computer. Can i just ask, what does <> mean, if i put in

    Code:
    If Left(oPrinters.Item(i), 3) <> "LY1" then
    		wshNetwork.RemovePrinterConnection oPrinters.Item(i+1), true, true
    			end if
    just want to know what symbol i would put in to replace <> that will equal LY1

  3. #33
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    3,035
    Thank Post
    305
    Thanked 293 Times in 203 Posts
    Rep Power
    120

    Re: A Printer Script

    ahhh, thanks chris, yeah i had installed the printer manually, if you could have a look that would be great..

    Thanks

    Tim

  4. #34

    Geoff's Avatar
    Join Date
    Jun 2005
    Location
    Fylde, Lancs, UK.
    Posts
    11,803
    Thank Post
    110
    Thanked 583 Times in 504 Posts
    Blog Entries
    1
    Rep Power
    224

    Re: A Printer Script

    the "<>" is logically 'not equal to'

  5. #35
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    4,987
    Thank Post
    120
    Thanked 283 Times in 261 Posts
    Rep Power
    107

    Re: A Printer Script

    What I was thinking off isnt going to help. Basically i= the IP Address and i +1= the share name. So how this works with local ports im not sure. Try echoing out the printer found within the loop with wscript.echo i & i+1 .

  6. #36
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: A Printer Script

    In my printer script ive removed the 'step 2' out the for loop and i just use i instead of of i+1 i.e.

    Code:
    FOR Counter = 0 to oPrinters.Count - 1
    	IF mid(oPrinters.Item(Counter), 1, 2) = "\\" THEN
    		PrinterPath = oPrinters.Item(Counter)
    		WshNetwork.RemovePrinterConnection PrinterPath, True, True
    	End If
    Next
    cant remember why i did that though ops:. With mine it looks for network printers so if i wanted to remove all printers then all i need to do is remove the if statement. Just to be certain, the printer you are trying to remove... is it Parallel or USB?

  7. #37
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    3,035
    Thank Post
    305
    Thanked 293 Times in 203 Posts
    Rep Power
    120

    Re: A Printer Script

    im trying to get rid of a printer that is set up manually on a computer by local port with the port name of \\server\printer. The printer isnt physically connected to the machine, its attached to a print server on the network, hence the path and port name \\server\printer. Looks like ill have to go round all computers and delete the printer manually.

  8. #38
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: A Printer Script

    Oh right gotcha... sorry i was being thick, you had said that before. ok try my script ie remove the step 2 and the i+1. if that doesnt work run these scripts to see what is outputed.

    1:
    Code:
    on error resume next
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    dim Counter, PrinterPath
    dim strConnectString, strResult
    
    'Remove All Network Printers.
    
    Set oPrinters = WshNetwork.EnumPrinterConnections
    
    For i = 0 to oPrinters.Count - 1 Step 2
                 	wscript.echo oPrinters.Item(i+1)
    Next
    2:
    Code:
    on error resume next
    Set WshNetwork = WScript.CreateObject("WScript.Network")
    dim Counter, PrinterPath
    dim strConnectString, strResult
    
    'Remove All Network Printers.
    
    Set oPrinters = WshNetwork.EnumPrinterConnections
    FOR Counter = 0 to oPrinters.Count - 1
    		WScript.Echo oPrinters.Item(Counter)
    Next

  9. #39
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: A Printer Script

    ops: seems that ive done multiple posts some how when i edited the post.. sorry. Can Edugeek admins pls delete the duplicates.

  10. #40
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    3,035
    Thank Post
    305
    Thanked 293 Times in 203 Posts
    Rep Power
    120

    Re: A Printer Script

    Ive taken out the step 2 and the i+1 but nothing happened, then
    code 1. gives me outputs of what printers i have. With regards to the LY1 local port printeri have got an output of LY1-2200. then
    Code 2. give me outputs of the ports the printers are using as well as the printer names. With regards to the locally installed printer, the first message is \\hades\ly1-2200 and the second message is LY1-2200. Obviously the first one is the port name and the second is the name of the printer.

  11. #41
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: A Printer Script

    Ok something odd is going on here as it doesnt look like anything is wrong with your script but you could try and remove just that printer by doing to following without the for loop:

    Code:
    WshNetwork.RemovePrinterConnection "\\hades\ly1-2200", True, True
    that should just remove your printer, hope it works for ya.

  12. #42
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    3,035
    Thank Post
    305
    Thanked 293 Times in 203 Posts
    Rep Power
    120

    Re: A Printer Script

    still dont work.. sorry.. just done a google search and found this article, but cant make heads or tails of the script (as im new to scripting)

    http://www.visualbasicscript.com/m_1208/tm.htm

  13. #43
    timbo343's Avatar
    Join Date
    Dec 2005
    Location
    Leeds/York area, North Yorkshire
    Posts
    3,035
    Thank Post
    305
    Thanked 293 Times in 203 Posts
    Rep Power
    120

    Re: A Printer Script

    I think am going to delete the printer from the machines, as that looks like a regedit hack

  14. #44
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: A Printer Script

    Ok i know why you cant delete the printer... its because when you try and delete \\hades\ly1-2200, it tries to delete a network printer so here is what i found:

    Code:
    strComputer = "."
    Set objWMIService = GetObject("winmgmts:" _
        & "{impersonationLevel=impersonate}!\\" & strComputer & 
    
    "\root\cimv2")
    
    Set colInstalledPrinters =  objWMIService.ExecQuery _
        ("Select * from Win32_Printer where DeviceID = 'LY1-2200'")
    
    For Each objPrinter in colInstalledPrinters
        objPrinter.Delete_
    Next
    I tested it and it works. Ive changed it to suit your situation.

  15. #45
    apeo's Avatar
    Join Date
    Sep 2005
    Location
    Lost
    Posts
    1,612
    Thank Post
    95
    Thanked 115 Times in 111 Posts
    Rep Power
    42

    Re: A Printer Script

    Just read what you found and it seems that what i put doesnt always work so they did indeed do a reghack in the end using a script but have you tried the initial suggestion? ie the code above.

SHARE:
+ Post New Thread
Page 3 of 11 FirstFirst 1234567 ... LastLast

Similar Threads

  1. logon script for printer
    By ozzy in forum Scripts
    Replies: 6
    Last Post: 22nd November 2007, 03:03 PM
  2. Printer Script
    By faza in forum Scripts
    Replies: 9
    Last Post: 14th September 2007, 08:30 AM
  3. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 AM
  4. Add printer script not workling
    By mark in forum Windows
    Replies: 6
    Last Post: 15th September 2005, 10:07 AM
  5. Script to delete printer
    By tosca925 in forum Scripts
    Replies: 2
    Last Post: 31st August 2005, 07:45 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
  •