How to check if asp.net mvc 3 is installed?

I am trying to write a powershell script that will install asp.net mvc 3 if it is not already installed. How to check if a specific version of asp.net mvc 3 is installed?

+6
powershell
source share
3 answers

I think you cannot change the location of the installation folder, so you could simply:

test-path "${Env:ProgramFiles(x86)}\Microsoft ASP.NET\ASP.NET MVC 3" 
+10
source share

Another way (unfortunately quite slow) is to request WMI:

 $res = Get-WmiObject Win32_Product | Where {$_.Name -match 'ASP\.NET MVC 3'} if ($res -ne $null) { ... } 
+3
source share

I became curious and made the Win32_AddRemovePrograms class http://poshcode.org/2470 ... that works, but to be honest, you do not need this to check a specific product, you can just find this product identifier in the registry.

 test-path "hklm:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{DCDEC776-BADD-48B9-8F9A-DFF513C3D7FA}" 

Where {DCDEC776-BADD-48B9-8F9A-DFF513C3D7FA} is the product identifier for Asp.net MVC 3. You can double-check to make sure by checking the display name for it:

 (Get-ItemProperty "hklm:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{DCDEC776-BADD-48B9-8F9A-DFF513C3D7FA}" DisplayName).DisplayName -eq "Microsoft ASP.NET MVC 3" 
+2
source share

All Articles