Click here to Skip to main content
15,512,053 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:

I have developed an application in C# and created its setup installer and msi. I want to check the windows version before installing. I mean if its 95/98, etc then I don't want the user to install, as my application doesn't support those platforms. Any idea how can I know the platform and the bit (2000, XP, Vista, &, etc 32/64 bit) while installing the application ? As also got to execute a exe file based on which bit.

Any help is highly appreciated.

Dylan Morley 22-Feb-11 6:05am    
What have you used to create your installer?
All Time Programming 22-Feb-11 7:32am    
I have used Setup Project of Visual Studio 2008.

Unless you've either written a 64-bit-only app, or both a 32-bit and 64-buit version of your app, no, architecture doesn't typically matter. If you did either of those two things, here's one way to approach it:

0) Create the appropriate installer(s) for your application, and genetare the msi file.

1) Create a small 32-bit application that detects whether or not the OS is a 64-bit OS.

2) Create a 32-bit installer that runs this 32-bit app.

3) If your architecture detector detects a 32-bit OS, take the appropriate action (either run the 32-bit installer or refuse to install because your app is 64-bit only).

4) If your architecture detector detects a 64-bit OS, take the appropriate action (run the 64-bit installer).
Share this answer
All Time Programming 22-Feb-11 8:11am    
Thanks John, Actually the setup needs to install a driver in installation proess. And the exe file for the drive differs for 32 & 64 bit. In that case wanted to know if in installtion I can find the architecture then can execute respective exe file only (I guess using some Custom Actions that are meant for such things.). The whole application runs on 32 and 64 bit finely, just this driver installation is causing the problem. I have writen code in my app, that can tell me the OS, and architecture, but that will be executed after install & while executing. I want to install the driver while installation only.
I hope I have made myself very clear. In this case how to tackle.

#realJSOP 22-Feb-11 9:34am    
I already told you how to do this. It's in the answer you replied to.
All Time Programming 22-Feb-11 9:59am    
John, I can create a small app that helps meknow the system is of 32 or 64 bit and I create an installer for the same. From my main installer I will run the above installer. How will the main installer know the results that are found by the 32 bit installer ? I don't get how will be the flow. Created a 32 bit (detect 32/64 bit) installer and other 2 installers for main app for 32 bit and 64 bit. Now how to proceed, I don't understand you that flow. Unless I don't execute the 32bit application, how can I even note anywhere the system info. Can you please clear it .

All Time Programming 23-Feb-11 6:11am    
John, I made a 32bit and 64bit versions of my app. And als oa 32bit detector app. Am not able with the further steps. Can you please be precise about it and help me out. Thanks.
You can get the version of the OS using VersionNT[^] Then you need to decide which OS version want to support. If the OS is supported continue, else quit the install.
Share this answer
All Time Programming 23-Feb-11 6:07am    
I don't want version, I want architecture. If I get Version as Vista, then that's avaialble for 32 bit also and 64 bit also. So architecture is imp than version and VersionNT provides only version. Thanks. Any way to find architecture.
Yusuf 23-Feb-11 8:57am    
You have to look harder. We can not solve ALL your issues. you asked for two things and I pointed you for one solution and the second one was right there as well. Hello Open you eyes
You cannot check the operating system in your installer because your installer will not run on Windows 95 or Windows 98. In order to perform checks on the operating system you need a running process. The user will receive a message that the installer could not be started.

Good luck!

Share this answer
All Time Programming 22-Feb-11 7:34am    
Thanks Eduard,
Can you tell something more about the "running process" in the SEtup Project to identify the windows version. And an idea on how to work out.
Eduard Keilholz 22-Feb-11 7:45am    
In order to install a .NET application, you need a setup project (which you have). The setup project compiles a Windows Installer file (msi) which can then be installed. The MSI however, requires Microsoft Windows Installer to be installed on the target machine together with the .NET Framework. If one of both is not available, your setup (msi) will never start. Therefore it will make no sense to check for a 'supported' OS, because your setup will never run on an unsupported target machine.
Most installer packages (like InstallShield) have the ability to determine the Windows version and subsequently allow you to write an installer script that handles your app's requirements for different Windows versions.

.Net apps won't run on anything older than Windows 2000, and I'm not sure if .Net 4 will even run on Win2K...
Share this answer
All Time Programming 22-Feb-11 7:37am    
Ok, so windows version may not be a factor for me but architecture is surely is. While installation, based on 32/64 bit have to execute an exe file. I use Setup Project of Visual Studio. Can you tell something about this.
#realJSOP 22-Feb-11 7:42am    
I'm pretty sure the installers also have the same thing for bitness determination. Try using google.
If you can use code in your setup, then you can check whether a registry key exists or not. HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node.
This key is only present if a 64 bits version of Windows is installed.

This solution works only for Windows of course...
Share this answer
All Time Programming 22-Feb-11 8:42am    
Thanks Olivier,

can you or anyone tell how to check the registry node in installation file ???
Olivier Levrey 22-Feb-11 9:23am    
In the solution explorer, click the registry editor button, then use "search target machine". I am not used to Setup Deployment but I think this is the way to retrieve values from the registry. Have a look to this link for example:
or this one:
All Time Programming 23-Feb-11 6:05am    
Thanks Oliver, But if that key is found the value returned is "" as their is only Default property whose value is "". If the key isn't found then also the value remains "" only. So it doesn't help in either ways.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900