cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
bbarton11
Pilgrim

Code Working Differently on Win2K8 64-bit than Win7 32-bit

Hi All,

I have a simple script that I'm running to detect if MS SQL Server 2008 R2 or better is installed on a machine before the installation proceeds. It seems to work just fine on my Windows 7 32-bit machine but fails on my Windows 2008 64-bit machine. What looks like is happening is that it's reading only part of the registry keys (100, 90, etc) under HKLM\SOFTWARE\Microsoft\Microsoft SQL Server. On Win2K8 64-bit it's breaking because it's skipping right over MSSQL10_50.xxxxx.

Any ideas what might be wrong? The SSRS section works fine.

// Create list of prereqs that may be missing from the machine.
//
// Microsoft SSRS
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szMSSSRS = MSSSRS;
szSubKey = "SOFTWARE\\Microsoft\\Microsoft SQL Server";
listResults = ListCreate(STRINGLIST);
listPrereqs = ListCreate(STRINGLIST);
listPrereqsMissing = ListCreate(STRINGLIST);
nItem = REGDB_KEYS;
nResult = 0;
nStartRSVersion = 0;
nLengthRSVersion = 9;
nSSRSInstalled = -1;
szValidRSVersion = "MSRS10_50";
RegDBQueryKey(szSubKey, nItem, listResults);
// Get the first string in the list
nResult = ListGetFirstString(listResults, szString);
// Loop
while (nResult != END_OF_LIST)
// Extract characters from the current item in the list
StrSub(svSubStr, szString, nStartRSVersion, nLengthRSVersion);
if (svSubStr = szValidRSVersion) then
nSSRSInstalled = 0;
endif;
// Get the next item in the list
nResult = ListGetNextString(listResults, szString);
endwhile;
if (nSSRSInstalled != 0) then
ListAddString(listPrereqsMissing, szMSSSRS, AFTER);
endif;
// Destroy list
ListDestroy(listResults);

// Microsoft SQL Server 2008 R2
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szSubKey = "SOFTWARE\\Microsoft\\Microsoft SQL Server";
listResults = ListCreate(STRINGLIST);
listPrereqs = ListCreate(STRINGLIST);
listPrereqsMissing = ListCreate(STRINGLIST);
nItem = REGDB_KEYS;
nResult = 0;
nStartSQLVersion = 0;
nLengthSQLVersion = 10;
nSQLServerInstalled = -1;
szValidSQLVersion = "MSSQL10_50";
szMSSQLServer2008R2 = MSSQLSERVER2008R2;
RegDBQueryKey(szSubKey, nItem, listResults);
// Get the first string in the list
nResult = ListGetFirstString(listResults, szString);
// Loop
while (nResult != END_OF_LIST)
// Extract characters from the current item in the list
StrSub(svSubStr, szString, nStartSQLVersion, nLengthSQLVersion);
if (svSubStr = szValidSQLVersion) then
nSQLServerInstalled = 0;
endif;
// Get the next item in the list
nResult = ListGetNextString(listResults, szString);
endwhile;
if (nSQLServerInstalled != 0) then
ListAddString(listPrereqsMissing, szMSSQLServer2008R2, AFTER);
endif;
// Destroy list
ListDestroy(listSubKeys);
Labels (1)
0 Kudos
1 Reply
joshstechnij
Pilgrim

Re: Code Working Differently on Win2K8 64-bit than Win7 32-bit

Since InstallScript runs in a 32-bit process, you will see only the 32-bit part of HKLM\Software on a 64-bit machine. To be able to see the 64-bit part, set REGDB_OPTION_WOW64_64KEY
in the REGDB_OPTIONS variable before accessing any HKLM\Software keys. Once you are finished with your registry checks, clear REGDB_OPTION_WOW64_64KEY
to ensure subsequent registry access for HKLM\Software is for the 32-bit registry. Please see the REGDB_OPTIONS help article for more information.
0 Kudos