Please disregard. Solved on my own.

Please disregard.. Didn't know how to remove a question.
Dennis DAsked:
Who is Participating?
 
Dennis DConnect With a Mentor Author Commented:
I was fighting with setting up a variable array using HTA/VBScript.  I had 3 lines in my code that looked like this where Service Name was entered manually in all 3 lines for each service I wanted to access:

Set colItems = objWMIService.ExecQuery("Select * From Win32_Service Where DisplayName = 'Service Name' Or DisplayName = 'Service Name' Or DisplayName = 'Service Name'")

Open in new window


I set up a variable array like this:

Dim sService(20)

' List of services
sService(0) = "Service Name"
sService(1) = "Service Name"
sService(2) = "Service Name"
sService(3) = ""
sService(4) = ""
sService(5) = ""
sService(6) = ""
sService(7) = ""
sService(8) = ""
sService(9) = ""
sService(10) = ""
sService(11) = ""
sService(12) = ""
sService(13) = ""
sService(14) = ""
sService(15) = ""
sService(16) = ""
sService(17) = ""
sService(18) = ""
sService(19) = ""

Open in new window


And now my 3 lines of code look like this:

Set colItems = objWMIService.ExecQuery("Select * From Win32_Service Where DisplayName = '" & sService(0) & "' Or DisplayName = '" & sService(1) & "' Or DisplayName = '" & sService(2) & "' Or DisplayName = '" & sService(3) & "' Or DisplayName = '" & sService(4) & "' Or DisplayName = '" & sService(5) & "' Or DisplayName = '" & sService(6) & "' Or DisplayName = '" & sService(7) & "' Or DisplayName = '" & sService(8) & "' Or DisplayName = '" & sService(9) & "' Or DisplayName = '" & sService(10) & "' Or DisplayName = '" & sService(11) & "' Or DisplayName = '" & sService(12) & "' Or DisplayName = '" & sService(13) & "' Or DisplayName = '" & sService(14) & "' Or DisplayName = '" & sService(15) & "' Or DisplayName = '" & sService(16) & "' Or DisplayName = '" & sService(17) & "' Or DisplayName = '" & sService(18) & "' Or DisplayName = '" & sService(19) & "'")

Open in new window


After fighting with it for way longer than I care to admit, I realized my problem was a simple syntax error.  I kept putting double quotes outside single quotes for each variable in the array, and it needed to be single quotes outside double quotes.
0
 
Peter HartCommented:
what question?  :
0
 
Dennis DAuthor Commented:
Answered my own question
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.