+ Post New Thread
Results 1 to 15 of 15
Wireless Networks Thread, Script translation please! in Technical; I haven't got my riddle solving head on today, so could someone tell me what this is doing? Trying to ...
  1. #1

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546

    Script translation please!

    I haven't got my riddle solving head on today, so could someone tell me what this is doing? Trying to work out how to add a printer if they're on a certain pc.

    if left(compname,6) = "SUITE1" then

    PrinterPath = "\\curricsvr1\JUNIOR-SUITE"
    PrinterPath2 = "\\curricsvr1\DJ1220C"
    PrinterPath3 = "\\curricsvr1\DJ2000C"
    WshNetwork.AddwindowsPrinterConnection PrinterPath
    WshNetwork.AddwindowsPrinterConnection PrinterPath2
    WshNetwork.AddwindowsPrinterConnection PrinterPath3
    WshNetwork.SetDefaultPrinter "\\curricsvr1\JUNIOR-SUITE"

    end if

    Ta!

  2. #2

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,104
    Thank Post
    891
    Thanked 1,752 Times in 1,511 Posts
    Blog Entries
    12
    Rep Power
    457
    if the computer name begins with "SUITE1" it will add those printers and make a printer called JUNIOR-SUITE the defult printer

  3. Thanks to FN-GM from:

    Little-Miss (13th October 2008)

  4. #3
    danrhodes's Avatar
    Join Date
    Sep 2008
    Location
    Wath Upon Dearne
    Posts
    1,513
    Thank Post
    157
    Thanked 181 Times in 150 Posts
    Rep Power
    68

    Cool

    Hey,

    This is a basic VB Script, it is adding printers and as far as I can tell it is trying to add them determined on their name. If this was my riddle I would prob use CMD script.

    "@ECHO OFF

    IF %HOSTNAME% = "AHOSTNAME1" {
    REM ----ADD PRINTER GLOBALLY FOR AN USER THAT LOGS ON----
    RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /ga /n \\SERVERNAME2\PRINTERSHARE2
    REM ---- RESTART THE PRINT SPOOLER SERVICE----
    NET STOP SPOOLER
    NET START SPOOLER
    }

    IF %HOSTNAME% = "AHOSTNAME2" {
    REM ----ADD PRINTER GLOBALLY FOR AN USER THAT LOGS ON----
    RUNDLL32 PRINTUI.DLL,PrintUIEntry /y /ga /n \\SERVERNAME2\PRINTERSHARE2
    REM ---- RESTART THE PRINT SPOOLER SERVICE----
    NET STOP SPOOLER
    NET START SPOOLER
    }

    EXIT"

    LET ME KNOW IF YOU NEED ANY MORE HELP.

    DAN

  5. #4

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546
    cool. Whats the 6 after the compname refering too?

  6. #5

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    The 'left' function takes a string (which is held in compname) and a number, and returns that many characters beginning at the start of the string. So left(compname,6) gets the first six characters in the computer name.

  7. Thanks to powdarrmonkey from:

    Little-Miss (13th October 2008)

  8. #6

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    Take 6 characters from the left of the computer name. I'm guessing your PCs are named something like suite10, suite11, suite12 etc??

    Provided you have got a good naming convention then it's easy to take part of the name and work with it to do things like deciding where a machine is and which printer it should get. Other things to look for are the mid and right functions which can extract other bits of the name (eg mid(compname,3,4) starts at character 3 and takes 4 characters - "ite1" and right(compname,2) would return "10" from the first name above)

    Dan's batch file works fine but you can probably imagine that it gets a bit longwinded if you have more than a few computers - picking the fragment of the name which identifies the room often keeps things simple!

  9. Thanks to srochford from:

    Little-Miss (14th October 2008)

  10. #7

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546
    Hmm, ok, i realised the computer i wanted was already on there (named differently to what i was expecting. I've not long started here to things aren't quite the way i'd have them)

    I added the printer i wanted. Logged in. I saw it run CMD and call the script. But then when i tried printers and faxes it wasn't there.

    Any ideas what i've done wrong. I copied the format from the previous entries?

  11. #8

    Join Date
    Mar 2007
    Posts
    1,802
    Thank Post
    85
    Thanked 297 Times in 228 Posts
    Rep Power
    87
    can we see the new script little-miss?

  12. #9

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546
    It's not my code, i've just added a line lol

    Code:
    on error resume next
    
    Set WshNetwork = CreateObject("WScript.Network")
    
    Dim Compname
    
    Compname = WSHNetwork.ComputerName
    
    if left(compname,6) = "SUITE1" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR-SUITE"
    	PrinterPath2 = "\\curricsvr1\DJ1220C"
    	PrinterPath3 = "\\curricsvr1\DJ2000C"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\JUNIOR-SUITE"
    
    end if 
    
    
    if left(compname,3) = "JNR" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR-SUITE"
    	PrinterPath2 = "\\curricsvr1\DJ1220C"
    	PrinterPath3 = "\\curricsvr1\DJ2000C"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\JUNIOR-SUITE"
    
    end if
    
    if left(compname,3) = "TAR" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR-SUITE"
    	PrinterPath2 = "\\curricsvr1\DJ1220C"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\JUNIOR-SUITE"
    
    end if
    
    
    if left(compname,3) = "JUN" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR-SUITE"
    	PrinterPath2 = "\\curricsvr1\INFLIB"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\JUNIOR-SUITE"
    
    
    end if
    
    if left(compname,6) = "JUNLIB" then
    
    	PrinterPath =  "\\curricsvr1\INFLIB"
    	PrinterPath2 = "\\curricsvr1\KM2430DL"
    	PrinterPath3 = "\\curricsvr1\JUNIOR-SUITE"	
    	WshNetwork.AddwindowsPrinterConnection PrinterPath
    	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	wshNetwork.SetDefaultPrinter "\\curricsvr1\INFLIB"
    
    end if
    
    
    if left(compname,3) = "LSR" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR-SUITE"
    	PrinterPath2 = "\\curricsvr1\DJ1220C"
    	PrinterPath3 = "\\LSR-PC1\HP DeskJet 840C/841C/842C/843C"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    	WshNetwork.SetDefaultPrinter "\\LSR-PC1\HP DeskJet 840C/841C/842C/843C"
    
    end if
    
    if left(compname,8) = "INFSUITE" then 
    
    	PrinterPath = "\\curricsvr1\KM2430DL"
    	rem PrinterPath2 = "\\curricsvr1\INFLIB1"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\KM2430DL"
    
    end if
    
    if left(compname,3) = "INF" then 
    
    	PrinterPath = "\\curricsvr1\KM2430DL"
    	PrinterPath2 = "\\curricsvr1\INFLIB1"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\INFLIB"
    
    	
    end if
    
    
    if left(compname,3) = "HAR" then 
    
    	PrinterPath = "\\curricsvr1\JUNIOR-SUITE"
    	PrinterPath2 = "\\curricsvr1\DJ1220C"
    	PrinterPath3 = "\\curricsvr1\DJ2000C"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.AddwindowsPrinterConnection PrinterPath3
    
    end if
    
    
    if left(compname,6) = "JUNLIB" then 
    
    	PrinterPath = "\\curricsvr1\KM2430DL"
    	PrinterPath2 = "\\curricsvr1\DJ2000C"
      	WshNetwork.AddwindowsPrinterConnection PrinterPath
      	WshNetwork.AddwindowsPrinterConnection PrinterPath2
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\KM2430DL"
    
    
    end if
    
    
    if left(compname,6) = "RESOURCES" then
    
    	PrinterPath = "\\curricsvr1\TASROOM"
    	Printerpath2 = "\\curricsvr1\JUNIOR-SUITE"
    	WshNetwork.SetDefaultPrinter "\\curricsvr1\TASROOM"
    
    end if

  13. #10

    Join Date
    Jun 2008
    Location
    Essex
    Posts
    47
    Thank Post
    2
    Thanked 17 Times in 15 Posts
    Rep Power
    15
    If it is the resources printer that you are trying to add then you are missing the two lines:

    WshNetwork.AddwindowsPrinterConnection PrinterPath
    WshNetwork.AddwindowsPrinterConnection PrinterPath2

  14. Thanks to greatone from:

    Little-Miss (14th October 2008)

  15. #11

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546


    thank you!

  16. #12

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546
    ok, fixed that. I'm using smelly winsuite. Is there a way of sending it out to the workstations because it still hasnt worked.

  17. #13

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,157
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    You also can't count :-)

    if left(compname,6) = "RESOURCES" needs to be if left(compname,9) = "RESOURCES" - you're checking the first 9 characters

  18. Thanks to srochford from:

    Little-Miss (14th October 2008)

  19. #14

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546
    lol! But actually that might have been the person before me, but fair play, i didnt spot it!

  20. #15

    Little-Miss's Avatar
    Join Date
    Oct 2007
    Location
    London
    Posts
    5,516
    Thank Post
    2,389
    Thanked 765 Times in 463 Posts
    Blog Entries
    2
    Rep Power
    546
    Sorted! Thank you!

SHARE:
+ Post New Thread

Similar Threads

  1. [CLOSED] Layout Issue: English Translation
    By FN-GM in forum EduGeek.net Site Problems
    Replies: 6
    Last Post: 12th March 2008, 11:02 PM
  2. Apache Link Translation
    By ICTNUT in forum *nix
    Replies: 8
    Last Post: 4th March 2008, 01:37 PM
  3. Word 2007 Translation Issue
    By Blind in forum Windows
    Replies: 0
    Last Post: 14th February 2008, 04:10 PM
  4. Translation Software.
    By maniac in forum How do you do....it?
    Replies: 4
    Last Post: 5th December 2007, 12:34 PM
  5. Logon script & Printer script question.
    By Galway in forum Windows
    Replies: 3
    Last Post: 29th August 2007, 11:00 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
  •