Please disregard. Solved on my own.

Please disregard.. Didn't know how to remove a question.
Dennis DAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Peter HartCommented:
what question?  :
0
Dennis DAuthor 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dennis DAuthor Commented:
Answered my own question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.