Subscribe to the RSS feed then follow me on twitter at @mrlacey (misc) and @wpug (WPDev news)

Wednesday, March 05, 2008

installscript register ASP.NET 1.1 (if not registered)

For some reason, one of our ASP.NET 1.1 based products is often installed on machines where ASP.NET 1.1 is installed on the machine, but not registered with IIS. (They typically have 2.0 installed and registered though.)

To get around this issue, I have created the following InstallScript function.

function RegisterAspDotNet(hMSI)
STRING svPatAddFolderIconszApplicationPath;
NUMBER nvType, nvSize, nIsFlag;
begin
//Check the registry to see if ASP.NET 1.1 is installed
//We'll be looking in the HKLM hive
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);

//initialise to be sure of what started with
svPath = "";

//Try and read a value from the registry, which will exist if it is installed and registered
RegDBGetKeyValueEx("SOFTWARE\\Microsoft\\ASP.NET\\1.1.4322.0", "Path", nvType, svPath, nvSize);

//If path key does not exists, ASP.NET 1.1 is not registered with IIS
if (svPath == "") then
//Check it exists
nIsFlag = FILE_EXISTS;
szApplicationPath = WINDIR ^ "\\microsoft.net\\framework\\v1.1.4322\\aspnet_regiis.exe";
//To ensure that the path or filename is correctly enclosed in quotation marks,
LongPathToQuote(szApplicationPath,FALSE);
//Check if the exe file exists
if (Is (nIsFlag, szApplicationPath) == TRUE) then
//Register with IIS
LaunchAppAndWait(szApplicationPath, " -i", WAIT);
endif;
endif;

end;

I run this as a custom action in the Install UI Sequence after LaunchConditions. (If you're not doing a UI install, you really should check the software requirements first!)

Are you a Windows Phone developer? If so, you could be getting rewards for the apps you build and the success they achieve by joining Nokia's DVLUP program.

No comments:

Post a Comment