Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I can't get this printerscript to work!

Status
Not open for further replies.

Raziel014

Technical User
Nov 1, 2005
51
0
0
NO
I'm working on this script which is supposed to map a printer based on computer membership. But I can't it to work. Could anyone take a look at it please?

Note that I've put a msgbox strPrinter at the bottom just to find out if the function is working. And the message box doesn't even appear!

Code:
Sub Main()
Set objNetwork = WScript.CreateObject("WScript.Network")
' Navn på domene
strDomain = "Ringve"

' Hent datamaskinnavn
strComputerName = objNetwork.ComputerName

' Last inn referanse til vår datamaskin
Set objComputer = GetObject("WinNT://" & strDomain & "/" & strComputerName & ",computer")

'Legger til Printer
strPrinter = ""

Select Case CBool(-1)
   Case isComputerMember("Gymkontor")
       strPrinter = "\\Ringve-fil\Dell_Laser_Gymkontor"
   Case isComputerMember("Lærerbakrom")
       strPrinter = "\\Ringve-fil\Fargelaser_lærerbakrom"
   Case isComputerMember("Bibliotek")
       strPrinter = "\\Ringve-fil\Dell_Laser_Bibliotek"
   Case isComputerMember("FO03")
       strPrinter = "\\Ringve-fil\Dell_Fargelaser_FO03"
   Case isComputerMember("AA05")
       strPrinter = "\\Ringve-fil\HPLaser_AA05"
   Case isComputerMember("AA07")
       strPrinter = "\\Ringve-fil\HPLaser_AA07"
   Case isComputerMember("AA08")
       strPrinter = "\\Ringve-fil\HPLaser_AA08"
   Case isComputerMember("Østmarka IT")
       strPrinter = "\\Ringve-fil\Lexmark_Østmarka_IT-rom"
   Case isComputerMember("Østmarka lærerrom")
       strPrinter = "\\Ringve-fil\Kopimaskin_PHST-Lærerrom"
   Case isComputerMember("Arbeidsrom 3 og 4")
       strPrinter = "\\Ringve-fil\Kopimaskin_arbeidsrom_3og4"
   Case Else
       MsgBox "No Printer"
End Select
'objNetwork.AddWindowsPrinterConnection strPrinter
MsgBox strPrinter
End Sub
 
Have you tried stepping through the program to see exactly what the variables are being populated with

It looks like isComputerMember("Gymkontor")
is a function that returns a bool, is the program getting to this stage and is the function isComputerMember("Gymkontor") working correctly
 
Step thru from the beginning. Is it even going to Sub Main? You have to set the start up form before it will.

-David
2006 Microsoft Valueable Professional (MVP)
2006 Dell Certified System Professional (CSP)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top