Old 24th April 2013, 16:01   #1
lukbys
Junior Member
 
Join Date: Apr 2013
Posts: 2
Check if file exists by regular expression

I'm attempting to create an installer that checks if the user has Microsoft .Net 4.0 installed, and if he/she doesn't install it for them. The code I have so far to check if .Net is installed is as follows:

!define NETVersion "4.0"
IfFileExists "$WINDIR\Microsoft.NET\Framework\v${NETVersion}" NETFrameworkInstalled 0

The problem is that the version is almost never exactly 4.0, on my computer it's 4.0.30319 so the installer thinks I don't have .Net installed. In addition there's also .Net 4.5 out as well which may complicate things. Is there some way to use regular expressions (or some other technique) to check if a user has a file v${NETVersion}(\.\d+)?? or something similar?

Thanks in advance.
lukbys is offline   Reply With Quote
Old 24th April 2013, 17:55   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You should instead check the "Install" DWORD value is 1 under either of the following keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full
(Make sure you SetRegView 64 first if the OS is 64-bit).

Stu
Afrow UK is offline   Reply With Quote
Old 24th April 2013, 19:53   #3
lukbys
Junior Member
 
Join Date: Apr 2013
Posts: 2
Thanks Stu,

That looks like it might work, however when I look in my registry I find v4 and v4.0. What's the difference between these 2 entries?
lukbys is offline   Reply With Quote
Old 24th April 2013, 20:10   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If you look at the default value under v4.0, it contains "deprecated".

Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Tags
.net, regex

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump