cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
zaki_agha
Level 3

installscript custom function wont work

Hi
I have trouble debugging an installscript function that I created.
The function compiles without issue.
However, the logic must be failing somewhere.
I run the installation on a Windows Server 2008 machine and it does not set the public property VALIDATEDOPERATINGSYSTEM to 1.

1) Public Property.
I created a public property VALIDATEDOPERATINGSYSTEM which 0
by default.


2) Custom InstallScript Function.
I created a custom installscript function which compiles successfully.
The custom function checks the operating system version and edition.
If the operating system is XP SP2
OR Vista (Ultimate, Business, Enterprise)
OR Server (2003, 2008)
then the custom function sets the public property
VALIDATEDOPERATINGSYSTEM to 1.
otherwise it sets
VALIDATEDOPERATINGSYSTEM to 0.

3) Custom Action.
I have created a custom action that calls the custom function.
The execute sequence is "After ISSetupFilesExtract".
Return Processing is "Synchronous (Check Exit Code)".
In-script Execution is "Immediate Execution".

4) Install Condition.
I have added a check to the install conditions (under Installation Information
-> General Information) .
It checks to see if the public property
VALIDATEDOPERATINGSYSTEM is 1.
If the property is not 1, then Installshield halts installation.

5) Issue.
Even when I install on the valid operating systems such as XP SP2,
the installation halts.

6) Interactive debugging.
I am not sure whether InstallShield supports interactive debugging?

7) Code help.
I would greatly appreciate it, if someone could help me debug the following:

function Check_For_SupportedOperatingSystems()
NUMBER nResult;
NUMBER nvType;
STRING svValue;
NUMBER nvSize;
NUMBER nRootKey;
STRING szKey;
STRING szNumName;
NUMBER iServicePackLevel;
STRING sServicePackLevel;
STRING sEditionID;
STRING sCurrentVersion;
STRING svSubStr;
STRING szString;
NUMBER nStart;
NUMBER nLength;
STRING sResult;
begin

nRootKey = HKEY_LOCAL_MACHINE;
if RegDBSetDefaultRoot (nRootKey) < 0 then
MsiSetProperty(ISMSI_HANDLE, "VALIDATEDOPERATINGSYSTEM", "0");
return 0;
Exit
endif;

nvType = 0;
svValue = "";
nvSize = 0;
szKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
szNumName = "CurrentVersion";
if RegDBGetKeyValueEx (szKey ,
szNumName,
nvType,
svValue,
nvSize )
= 0 then
svSubStr ="";
StrSub ( svSubStr, svValue, 0,3 );
sCurrentVersion = svSubStr;
else
MsiSetProperty(ISMSI_HANDLE, "VALIDATEDOPERATINGSYSTEM", "0");
return 0;
Exit
endif;

nvType = 0;
svValue = "";
nvSize = 0;
szKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
szNumName = "EditionId";
if RegDBGetKeyValueEx ( szKey,
szNumName,
nvType,
svValue,
nvSize )
= 0 then
//The operating system is either Vista or Server 2008
sEditionID = svValue;
else
sEditionID = "";
endif;

nvType = 0;
svValue = "";
nvSize = 0;
szKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
szNumName = "CSDVersion";
if RegDBGetKeyValueEx ( szKey,
szNumName,
nvType,
svValue,
nvSize )
= 0 then
//The operating system is either Vista or Server 2008
sServicePackLevel = svValue;
StrSub ( svSubStr, sServicePackLevel, 13, 2 );
sServicePackLevel = svSubStr;
StrSub ( svSubStr, sServicePackLevel, 1, 1 );
if StrCompare ( svSubStr, " " ) = 0 then
StrSub ( svSubStr, sServicePackLevel, 0, 1 );
sServicePackLevel = svSubStr;
endif;
StrToNum ( iServicePackLevel, sServicePackLevel );
else
sServicePackLevel = "";
iServicePackLevel = 0;
endif;

nResult = 0;

//XP
if sCurrentVersion = "5.1" then
if iServicePackLevel >= 2 then
nResult = 1;
endif;
endif;

//Windows Server 2003
if sCurrentVersion = "5.2" then
nResult = 1;
endif;

//Windows Server 2008 And Vista
if sCurrentVersion = "6.0" then
//Windows Server 2008
svSubStr ="";
StrSub ( svSubStr, sEditionID, 0,6 );
if svSubStr = "Server" then
nResult = 1;
endif;
//Windows Vista Ultimate
svSubStr ="";
StrSub ( svSubStr, sEditionID, 0,8 );
if svSubStr = "Ultimate" then
nResult = 1;
endif;
//Windows Vista Business
svSubStr ="";
StrSub ( svSubStr, sEditionID, 0,8 );
if svSubStr = "Business" then
nResult = 1;
endif;
//Windows Vista Enterprise
svSubStr ="";
StrSub ( svSubStr, sEditionID, 0,10 );
if svSubStr = "Enterprise" then
nResult = 1;
endif;
endif;
NumToStr ( sResult, nResult );
MsiSetProperty(ISMSI_HANDLE, "VALIDATEDOPERATINGSYSTEM", sResult);
return nResult;
end;
Labels (1)
0 Kudos
(8) Replies
RobertDickau
Flexera Alumni

Before following this path, could you perhaps use the built-in MSI properties VersionNT, WindowsBuild, MsiNTProductType, ServicePackLevel, and so forth to detect the target operating system instead of reading from the registry?

The MSI help topic "Operating System Property Values" will give you some information to get started; and you can use conditions made from these properties to control set-a-property custom actions that set your VALIDATED_OPERATING_SYSTEM property...
0 Kudos
zaki_agha
Level 3

Hi Robert,
Thanks for the reply.
The built-in functions do not provide the granularity that I require.
I need to specify specific editions of the Vista operating system.
My application is supported only on XP (SP2 or greater),
Vista (Ultimate, Business and Enterprise), Server (2003 and 2008).

Thanks
Zaki
0 Kudos
TheTraveler
Level 8

Have you looked into, SYSINFO? It is a structure that gets populated as soon as you run the installation.

SYSINFO.nISOSL

ISOSL_WIN95—Windows 95
ISOSL_WIN98—Windows 98
ISOSL_WINME—Windows Millennium Edition
ISOSL_NT40—Windows NT 4.0
ISOSL_WIN2000—Windows 2000
ISOSL_WINXP—Windows XP Edition
ISOSL_WINSERVER2003—Windows Server 2003
ISOSL_WINVISTA—Note that the installation considers Windows Server "Longhorn" to be the same as Windows Vista; thus, components that are marked for Windows Vista are also installed on Windows Server "Longhorn."

If SYSINFO.nISOSL = ISOSL_WINSERVER2003 Then
Return True
End If


SYSINFO.WINNT.nServicePack
The number of the installed service pack on Windows NT, 2000, Windows XP, Windows Server 2003, and any other future operating system (that is, Windows NT 4.0 and later).

Note that for Windows 2000 and later, the installation obtains this information by calling the Windows API GerVersionEx and reading the nServicePackMajor value.

On systems with platforms earlier than Windows 2000, the installation obtains this information from the appropriate service pack registry location.
0 Kudos
zaki_agha
Level 3

Thanks for the info on the SYSINFO object.
It does not provide me with the required granularity to check the editions of the operating system.

I would greatly appreciate it, if someone could tell me how to debug an installscript custom action.

I have a BASIC MSI installer.
I can use the MSI Debugger to start the debugging.
It breaks on the custom action that calls the installscript function.
The function is in Setup.rul.
I have ensured that I have registered the Isdbg.exe.
I have the required files in the Script Files directory (Setup.rul
, Setup.dbg, Setup.inx )

Thanks
0 Kudos
TheTraveler
Level 8

Maybe I don't understand how in depth you need to know the windows version, but did you look at this?

SYSINFO.nWinMajor = Value indicates Windows major version number.

SYSINFO.nWinMinor = Value indicates Windows minor version number.

SYSINFO.WINNT.nServicePack = The number of the installed service pack on Windows NT, 2000, Windows XP, Windows Server 2003, and any other future operating system (that is, Windows NT 4.0 and later).

Note that for Windows 2000 and later, the installation obtains this information by calling the Windows API GerVersionEx and reading the nServicePackMajor value.

On systems with platforms earlier than Windows 2000, the installation obtains this information from the appropriate service pack registry location.

As for debugging the install shield script, why not run it through the development enviroment? If that isn't an option, you install or copy the ISDbg.exe onto the target machine. You can look up on to do that in the help(Debugging an Installation on Any Computer). I'm not entirely sure if it will work with Basic MSI installations. You could always make a temporary Install Shield script installation project and run your code in the development enviroment. Better yet, you could use the Install Shield Script MSI project. Which use both MSI and install shield scripting engine.

I looked it up, this is from the Install Shield Help:
ISDbg.exe file (for InstallScript projects) or ISDbgCnv.exe (for InstallScript MSI projects)
0 Kudos
RobertDickau
Flexera Alumni

You should be able to distinguish among many more versions/editions using MsiNTSuitePersonal, MsiNTSuiteEnterprise, etc., along with the MsiNTProductType, VersionNT, and other properties mentioned before. The MSDN documentation for OSVERSIONINFOEX can help with the mapping...
0 Kudos
zaki_agha
Level 3

Thanks for the help.
I got my function working.

Here is what I was doing wrong:
1) The function definition needs a handle as a parameter.
function Check_For_SupportedOperatingSystems(hMSI)
2) Each call to MsiSetProperty must use the handle "hMSI".

Thanks
Zaki
0 Kudos
RayKode
Level 6

Were you ever able to resolve this ?

I have the exact issue and I'm not able to figure out what to do.


With SYSINFO, I CAN determine if the OS if XP home edition.
(IS sites an example in thier documentation.)

But, I also need the abaility to tell if the the OS is Vista HOME.

And it would be way nice to be able to determine if it is Vista HOME basic or Vista HOME Permimum as well.

Thanks for any information that you may be able to share.

Ray in Wisconsin 🙂
0 Kudos