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!

Wildcards maybe of use in this script ???

Status
Not open for further replies.

djlax152

IS-IT--Management
Jun 20, 2003
18
0
0
US
Something crossed my mind while i was writing this script, myabee you might know this. I was thinking since my computers are named 5001-CL<- followed by the computer number (CL standing for what room it is i.e computer Lab) that maybee instead of writing 5001-CL01 , CL02 , CL03, ect.. ect.. that i could use a wildcard like 5001-CL??.. I tried it like this but it didnt work is there another method to tell the script that i dont care what the last two digits are as long as it is 5001-CL "then" do blah blah
 
Something like this ?
If Left(strComputer, 7) = "5001-CL" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Can you break that down for me a little bit more im not sure how i could incorp that with my script ? Thanks for the Patience (im still learning)
 
how i could incorp that with my script
Which script ?
Sorry, the crystal bowl is in vacation today and I'm not a mindreader.
 
Option Explicit

'Declaring Variables
Dim obj2200
Dim obj810c
Dim unc2200CL
Dim unc810ccl
Dim Objcomputername
Dim Computername

'Set type
Set obj2200 = CreateObject("Wscript.Network")
Set obj810c = CreateObject("Wscript.Network")
Set objcomputername = Wscript.CreateObject("Wscript.Network")

'Introducing values to variables
UNC2200cl = "\\5001-CL31-6488\2200"
unc810ccl = "\\5001-CL31-6488\810c"
computerName = objcomputername.ComputerName

'Script body

if ucase(Computername) = "5001-ADMIN01"_
or ucase(computername) = "5001-ADMIN02"_
or ucase(computername) = "5001-CL01"_
or ucase(computername) = "5001-CL02"_
or ucase(computername) = "5001-CL03"_
or ucase(computername) = "5001-CL04"_
or ucase(computername) = "5001-CL05"_
or ucase(computername) = "5001-CL06"_
or ucase(computername) = "5001-CL07"_
or ucase(computername) = "5001-CL08"_
or ucase(computername) = "5001-CL09"_
or ucase(computername) = "5001-CL10"_
or ucase(computername) = "5001-CL11"_
or ucase(computername) = "5001-CL12"_
or ucase(computername) = "5001-CL13"_
or ucase(computername) = "5001-CL14"_
or ucase(computername) = "5001-CL15"_
or ucase(computername) = "5001-CL16"_
or ucase(computername) = "5001-CL17"_
or ucase(computername) = "5001-CL18"_
or ucase(computername) = "5001-CL19"_
or ucase(computername) = "5001-CL20"_
or ucase(computername) = "5001-CL21"_
or ucase(computername) = "5001-CL22"_
or ucase(computername) = "5001-CL23"_
or ucase(computername) = "5001-CL24"_
or ucase(computername) = "5001-CL25"_
or ucase(computername) = "5001-CL26"_
or ucase(computername) = "5001-CL27"_
or ucase(computername) = "5001-CL28"_
or ucase(computername) = "5001-CL29"_
or ucase(computername) = "5001-CL30"_
or ucase(computername) = "5001-CL31"_
or ucase(computername) = "5001-CL32" Then
obj2200.AddWindowsPrinterConnection UNC2200cl
obj810c.addwindowsprinterConnection Unc810ccl
obj2200.setdefaultprinter UNC2200cl
End if

'Confirmation


THIS ONE !
 
djlax152 wrote:
>obj2200.AddWindowsPrinterConnection UNC2200cl
>obj810c.addwindowsprinterConnection Unc810ccl

What ever improvement on the conditional test you can make, you need to furnish two arguments. Check the documentation.

- tsuji
 
I confirm the answer is in my first reply, replacing If by Or and strComputer by UCase(computername)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
'Map Printers for Shenandoah
'Drew Dorben Jan 28th
'---------------------------'

Option Explicit

'Declaring Variables
Dim obj2200
Dim obj810c
Dim unc2200CL
Dim unc810ccl
Dim Objcomputername
Dim Computername
DIM strComputer

'Set type
Set obj2200 = CreateObject("Wscript.Network")
Set obj810c = CreateObject("Wscript.Network")
Set objcomputername = Wscript.CreateObject("Wscript.Network")

'Introducing values to variables
UNC2200cl = "\\5001-CL31-6488\2200"
unc810ccl = "\\5001-CL31-6488\810c"
computerName = objcomputername.ComputerName

'Script body

If Left ucase(computername, 7) = "5001-AD" Then
obj2200.AddWindowsPrinterConnection UNC2200cl
obj810c.addwindowsprinterConnection Unc810ccl
obj2200.setdefaultprinter UNC2200cl
End IF



Here is what i have it works great !! only one flaw i cant get the Ucase to work. when i run this scrip its says

error line 28
char 9
expected 'Then'
 
if Left(ucase(computername, 7)) = "5001-AD" Then
 
my bad
if Left(ucase(computername), 7) = "5001-AD" Then
 
Hmm Its seeems to be ingnoring the Ucase because
when i put If Left(ucase(computername),7) = "5001-ad" then it did not work no errors or anything just didnt map the printers
when i put If Left(ucase(computername),7) = "5001-AD" then it did work! (notice the caps in AD)
 
UCase stands for UPPERcase

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
DOes this mean that computernames that were named in lowercase will work also as loong as i put Ucase and 5001-CAPS ??
 
Yes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
okay Thank your for all of your help PHV !! & tsuji !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top