Strange problem, For Each Populating Element with name of collelction

Got a problem you cannot solve? Try here.
Dame1701
Posts: 29
Joined: Tue Jan 05, 2016 10:33 am

Strange problem, For Each Populating Element with name of collelction

Postby Dame1701 » Thu Dec 05, 2019 5:36 am

I have a strange problem with an InstallAware script I'm trying to create. It is to detect SQL instances. I'm reading a set of registry values into a collection which i then want to iterate using the for each loop. Everything is working fine until the for each loop. The problem is that the variable SQL_INSTANCE_VALUE instead of being populated by the next element in the collection is being populated by the name of the collection, so when I place a watch over SQL_INSTANCE_VALUE I get the value SQL_INSTANCE_VALUES (which is the name of the variable representing the collection). I have determined this by running in Debug mode and setting a watch on the variables.

I can't figure out why this is the case, it doesn't make any sense why InstallAware would behave in this way. As I cannot find any FOR Each examples I am unsure as to whether I am doing things correctly. Here is my code:

Code: Select all

~InstallAware Clipboard Data~
~Comment~
~{F318EAEC-8074-4D75-8CAF-45839484D387}~
~~
~End~
~{00C5BB03-DE22-42B0-A369-2740FAB21A3D}~
~Next~
~{E311CF5A-2043-49AA-B714-6DA4C7AE80E5}~
~End~
~{DB2A7360-1E2F-42A5-A9A2-1137C055DA49}~
~Break~
~{2F1E6A6F-C79F-4B0D-9C1A-1401DAA9A60F}~
~Set Variable~
~{A5DD783C-529E-4417-B040-5BE1CB15B6F9}~
~INSTALLED_MICROSOFTSQLSERVEREXPRESS2014WITHSERVICEPACK2(X64)$MYAH$MYAH$FALSE~
~TRUE~
~If~
~{DEE6DB92-B129-4E9E-85E2-330B06459D59}~
~SQL_INSTANCE_VALUE~
~4~
~""~
~TRUE~
~For Each~
~{7ED3410F-A3AB-46F3-94FB-865BDD349B98}~
~SQL_INSTANCE_VALUE~
~$NEWLINE$~
~SQL_INSTANCE_VALUES~
~Find All Registry~
~{445ED113-C834-4026-844B-A13E5E968F62}~
~SQL_INSTANCE_VALUES|~
~2~
~SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL~
~FALSE~
~TRUE~
~If~
~{D1D3DD63-B8B6-4FC0-AC1E-43731A953519}~
~SQL_INSTANCES_KEY~
~0~
~NO$KEY~
~TRUE~
~Check Registry~
~{49FAB24F-24E3-4D49-A877-2F677D9F77EA}~
~SQL_INSTANCES_KEY|~
~2~
~SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names~
~SQL~


... and here it is as written in the editor

Code: Select all

  Check Registry Key HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL into SQL_INSTANCES_KEY
  if Variable SQL_INSTANCES_KEY not Equals NO$KEY
    Find All Registry Values in HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL into SQL_INSTANCE_VALUES
    for each Element SQL_INSTANCE_VALUE in $NEWLINE$ delimited Collection of SQL_INSTANCE_VALUES do
      if Variable SQL_INSTANCE_VALUE not Equals (Ignore Case) ""
        Set Variable INSTALLED_MICROSOFTSQLSERVEREXPRESS2014WITHSERVICEPACK2(X64) to TRUE
        Break out of Loop
      end
    next
  end


Does anyone know what I'm doing wrong. I have been trying to get this working for several days but no luck so far.

Many thanks,

Damien.

Dame1701
Posts: 29
Joined: Tue Jan 05, 2016 10:33 am

Re: Strange problem, For Each Populating Element with name of collelction

Postby Dame1701 » Thu Dec 05, 2019 6:13 am

I believe I have found the problem, instead of writing:

Code: Select all

for each Element SQL_INSTANCE_VALUE in $NEWLINE$ delimited Collection of SQL_INSTANCE_VALUES do


You actually need to do:

Code: Select all

for each Element SQL_INSTANCE_VALUE in $NEWLINE$ delimited Collection of $SQL_INSTANCE_VALUES$ do


I only found this by playing around. It would be useful if there were some examples in the help file as unless you're experienced with InstallAware you are unlikely to be able to know this stuff.

Hope this helps others,

Cheers,

Damien


Return to “Technical Support”

Who is online

Users browsing this forum: Bing [Bot] and 53 guests