Video Screencast Help

How to tell if the .Net 4 Framework installed or was cancelled.

Created: 15 Apr 2011 | 4 comments

How can I tell in my WSE where I'm trying to install the .Net 4 framework whether or not it installed or if the user cancelled?  Here is my .WSE code...

If COUNT Equals "1" then

Set Variable COUNT to 3


Set Variable FILEPATH1 to %WORKINGDIR%\FILEPATH1\RemoveOld.exe

Set Variable FILEPATH2 to %WORKINGDIR%\FILEPATH2\ dotNetFx40_Full_setup.exe

Install File .\Custom Actions\RemoveOld.exe to %FILEPATH1%

Install File C:\dotNetFx40_Full_setup.exe to %FILEPATH2%

Set Variable CMDLINE1 to

Execute %FILEPATH1% %CMDLINE1%(Wait)

Execute %FILEPATH2% %CMDLINE1%(Wait)


How can I tell after the Wait if the user cancelled the install or if it aborted?  I found the error codes it can produce on the Microsoft site and there is one for cancelled and one for fatal error.  I'd like to determine if either of those happened and then have it put up an appropriate message and cancel my install.  I was testing this and right now if I cancel the .Net install then it just proceeds with installing the rest of my app from my WSI.  Maybe I can't do this in the WSE and it has to be done in the WSI after this code in the WSE happens.  I really don't know.

Any help would be greatly appreciated.

Discussion Filed Under:

Comments 4 CommentsJump to latest comment

VBScab's picture

...should contain advice about how to detect the various flavours of the .Net Framework. I don't yet have 4.0 but, for version 2.0 to 3.5, there was keys in HKLM\Software\Microsoft\Net Framework Setup\NDP\[VersionString]. You can use that, along with the standard Windows Installer installation registry data (HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductCode] and, for the truly paranoid [cough, cough], you could get a key file's presence on disk and its version number.

Don't know why 'x' happened? Want to know why 'y' happened? Use ProcMon and it will tell you.
Think about using before posting.

EdT's picture

Microsoft have published a technical note on how to detect each version of .NET - the document is here:

It should therefore be quite simple to search for the relevant registry key for the version you are installing, to see if it is there, and then advise the user accordingly if it is not.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.

pbishop's picture

Thanks for the tips.  I knew I could do the registry, but for some reason I thought I'd be able to check the codes that come back form the Microsoft Installl.  Is that possible?  Just check the code and decide that way?

EdT's picture

This is a good time to open the Wisescript documentation (yes, I know that's the last thing we all think to do), and look up the runtime variable PROCEXITCODE - its near the end of the manual.

As the name implies, it holds the exit code of the last Execute program operation.  What you need to verify is that the exit code for different "failure" modes is what you would expect. Cancelling an install may not return an error code as its technically not an error situation. Combining a check of the error code with a check of the appropriate registry key will give you the most reliable method of assuring a good install.

If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.