/build/static/layout/Breadcrumb_cap_w.png

Case sensitive

This script reads a text file the matches it to pcname, then an if then statement is propesed to determine what comes next.
my text file is all caps, however when the netbios nbame is read it is sometimes lowercase. How would I edit my script to achieve non-case sensitive? I appreciate any help on this matter... Thank You!



Dim WSHShell, objWMIService, ColProcesses, oShell, sp, oEnv, WshNetwork, objIADsUser, objFSO, objFile, colMatches
Set oShell= CreateObject("Wscript.Shell")
Set oEnv = oShell.Environment("PROCESS")

'********************************************************************
'PC Name check for HTA
'********************************************************************

Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objIADsUser = GetObject("WinNT://" & WshNetwork.UserDomain & "/" & WshNetwork.UserName & ",user")
pcname = WshNetwork.ComputerName


Const ForReading = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = pcname
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("hta.txt", ForReading)

Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count = 1 Then
For Each strMatch in colMatches'
WScript.Quit [exitcode]

Next
End If
Loop

objFile.Close

0 Comments   [ + ] Show comments

Answers (3)

Posted by: pjgeutjens 13 years ago
Red Belt
2
pcname = UCase(WshNetwork.ComputerName)
Posted by: taz081175 13 years ago
Senior Yellow Belt
0
Thank you!
Posted by: captain_planet 13 years ago
Black Belt
0
Hmmm. Two things to note (unless I've got the wrong end of the stick here....).

1. To perform a case-insensitive regular expression, you should just use objRegEx.ignoreCase = true.

2. You say:

If colMatches.Count = 1 Then
For Each strMatch in

So in other words, if there's only one match, then loop through all the matches? Uh? That doesn't make sense. So, either:

a) Remove the 'For each....' loop OR

b) Remove the 'If....' statement, and add objRegEx.global = true to your regular expression.

[;)]
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ