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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

use wildcard string to check flow of script

Status
Not open for further replies.

chouck

MIS
Jan 30, 2005
32
US
I was wondering if anyone could tell me how to do this. I cna't figure it out and was looking for a bit of advice: what i want to do is take the first two characteres of a computername and use that as the indicator of which way the script shoul flow. for instance if i use one type of name for desktop pc's and one type of name for laptop pc's, i want to be able to determine the name and then script to act appropriately:

Desktop example name: dt1234
laptop example name: lt1234

Here is a sample of what i have so far:


set objshell = createobject("wscript.shell")
set objnet = Createobject("wscript.network")

wscript.echo objnet.computername

if computername = "lt*" then
wscript.echo "works"
else
wscript.echo "does not work"

end if

basically what i think i am trying to do is to parse out the results of the objnet.computername results to a partial string??

Any help greatly appreciated :)
 
If UCase(Left(computername, 2)) = "LT" Then

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
try this:

Code:
Select Case Ucase(left(computername,2))
	Case "LT"
		'Do stuff for Laptop
	Case "DT"
		'Do stuff for Desktop
	Case Else
		MsgBox "Wrong Computername!"
End select

Please tell me if I'm wrong I like to learn from my mistakes...
_____________________________________
Feed a man a fish and feed him for a day.
Teach a man to fish and feed him for a lifetime...
 
thank you to both of you, both of these solutions worked very well!!

This was gold and did exactly what I needed it to do. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top