Link to home
Start Free TrialLog in
Avatar of Christopher Schene
Christopher ScheneFlag for United States of America

asked on

In windows 7 how do I programmatically detect if .net is anabled?

How do I programmatically detect in .vbs whether .net is is abled.

For an extra 250 points, how do I enable it if it is not already enabled?
Avatar of dn0rm
dn0rm

this MS knowledge base article should point you in the right direction i believe...

http://msdn.microsoft.com/en-us/kb/kbarticle.aspx?id=318785

i don't know that you need to actually enable a .net framework unless you are talking about installing a web application - as you do need to enable it in IIS.

to install 2.0 on top of IIS (this happens if IIS is installed after .net framework, you can execute this command from the command line:

C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regiis.exe -i




Avatar of Todd Gerbert
I'm pretty sure Windows 7 ships with at least .Net 3.5 pre-installed, you probably don't need check (unless you're looking for .Net 4 specifically).
Avatar of Christopher Schene

ASKER

It seems part of my problem is that since I am running a 32 program (my 2008 installshield installer) I am reading values from HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node and writing to there was well. So when I try to read the registry key, I am unable to see it.

So, how do I access the "real (64 bit registry)" from a 32 bit app.

thanks,

chris
What is it, exactly, you're trying to accomplish - what is your ultimate end goal?  Your question was originally concerning detecting the presence of .Net Frameworks specifically under Windows 7 using VBScript, and now we appear to be moving to programming - I would prefer to skip complex intermediate steps before we finally come to what your question really is. ;)

But judging by your question, I am guessing that you are attempting to create a custom action for an installer to detect if the right .Net Framework for your application is installed (and this really is a bit of guess, which is why more info would be useful).

1. All Windows 7 installations already include .Net 3.5.

2. When .Net is installed on a 64-bit system it includes both 32- and 64-bit components, which means you can still follow the instructions dn0rm posted a link to, reading from HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node (which is just the 32-bit version of the registry).

3. I'm not familiar with InstallShield, but I would imagine there's a checkbox somewhere you can just click that says ".Net 3.5 or better is required for this application" and be done with it.

4. If you're programming in a .Net language, and you're at v4, you can use RegistryKey.OpenBaseKey() (http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.openbasekey.aspx) to get the 64-bit registry from a 32-bit application - otherwise you need to use the RegOpenKeyEx() API (http://msdn.microsoft.com/en-us/library/ms724897(VS.85).aspx).  You're probably out of luck if you're stuck in VBScript.
My ultimate goal is

1) to determine from my VBScript if .net 2.0 Sp1 or .net 2.0 SP2 is installed
2) If it is not installed, to install it

Now that I am working more with this, i do see that every Win7 or 2008 OS I have worked with so far has had .net installed (I did not know this at first), so my question may be unnecessary.

I do have another reason to access the registry and would like to read and write......I considred writing a VB.net app and running that from VBscript.
every Win7 or 2008 OS I have worked with so far has had .net installed (I did not know this at first)
http:#a34874144 ;)

Still, that should probably be a task that's handled by the InstallShield Installer anyway.  Like I said, I'm not familiar with InstallShield, but I know the Visual Studio Installer tool has an option to check for, and install if necessary, a specific .Net version.

Writing a .Net application to read/write the registry and launching it from VBScript would probably work out okay, however I could reconsider whether using the registry is necessary at all, and if so is it really necessary to get the 64-bit keys from a 32-bit application?

Will your application run as 64-bit?
Ok, I found an option in install shield......to disable or enable registry reflection (comments from the help page attached)....problem is when I go there, no such option for registry reflection is shown.

Here is the help infomration:

TASK

To enable or disable registry reflection for all new and existing registry keys that are affected by a component:

1.In the View List, under Organization, click Components.
1.In the Components explorer, select the component for which you want to configure the registry reflection setting.
1.To enable registry reflection, set the Disable Registry Reflection setting to No. This is the default value.
To disable registry reflection, set the Disable Registry Reflection setting to Yes.


--------------------------------------------------------------------------------

Enabling and Disabling Registry Reflection 
InstallShield 2008 

Registry reflection keeps the 32-bit registry view and the 64-bit registry view in sync on the target machine. 

 
Note

Only 64-bit systems with Windows Installer 4.0 support registry reflection. Other systems ignore the registry reflection setting. 

If an end user installs a 64-bit application that has a component with registry reflection enabled, Windows Installer makes the associated registry changes in the 64-bit view of the registry, and the reflector copies the registry changes to the 32-bit registry view. Similarly, if an end user then installs a 32-bit application that modifies the same registry key or value, Windows Installer makes the associated registry changes in the 32-bit view of the registry, and the reflector copies the registry changes to the 64-bit registry view. 

If registry reflection is disabled, Windows Installer calls the RegDisableReflectionKey function on each key being accessed by the component. This function disables registry reflection for the specified key. Disabling reflection for a key does not affect reflection of any subkeys. 

 
Task

To enable or disable registry reflection for all new and existing registry keys that are affected by a component: 

In the View List under Organization, click Components.
In the Components explorer, select the component for which you want to configure the registry reflection setting.
To enable registry reflection, set the Disable Registry Reflection setting to No. This is the default value.
To disable registry reflection, set the Disable Registry Reflection setting to Yes. 

For more information about registry reflection, see Registry Reflection in the MSDN Library. 


--------------------------------------------------------------------------------
InstallShield Help Library
23 May 2007
 Copyright Information | Contact Macrovision
 
 
   
  Popup

Open in new window

I can get a snap shot of the Installshield options if you would like to see them
ASKER CERTIFIED SOLUTION
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial