NET Framework 4 silent install


  1. Posts : 552
    Windows 8 Pro x64
       #1

    NET Framework 4 silent install


    I am developing a set of tools in Microsoft Visual C# 2010. I absolutely hate the Microsoft publishing tools in it so I want to create my own installer using Inno Setup. The problem is that most of the target audience for these tools do not even know what .NET Framework is, so I need to be able to launch a silent install in case they do not have it. How can I do this? Are there arguments that can be passed to the redistributable?
      My Computer


  2. Posts : 5,807
    Windows 7 Home Premium x64 - Mac OS X 10.6.4 x64
       #2

    Hmm....this might work....add these to the redistributable's exe....

    Code:
    /install /x86 /x64 /ia64 /parameterfolder Client /q /norestart
      My Computer


  3. Posts : 552
    Windows 8 Pro x64
    Thread Starter
       #3

    Zidane24 said:
    Hmm....this might work....add these to the redistributable's exe....

    Code:
    /install /x86 /x64 /ia64 /parameterfolder Client /q /norestart
    I figured that it had to be possible. I'll probably tell Inno Setup to launch an app which checks for the NET version installed, if any, and if the minimum version needed is not, the app will launch the redistributable with those parameters. I assume that there is something in the registry which I could have my c++ app read that would tell it what version of NET is installed.
      My Computer


  4. Posts : 5,807
    Windows 7 Home Premium x64 - Mac OS X 10.6.4 x64
       #4

    Grabbed this from a project of mine....

    Code:
    Dim DotNetFrameworkInfo As New DotNetFramework.SystemInfo
    Console.WriteLine(DotNetFrameworkInfo.HighestFrameworkVersion)
    Console.WriteLine(DotNetFrameworkInfo.NetFrameworkInstallationPath)
    Dim FrameworkVersionCollection As New Collection
    FrameworkVersionCollection = DotNetFrameworkInfo.FrameworkVersions
    For Each FrameworkVersion As String In FrameworkVersionCollection
    	Console.WriteLine(FrameworkVersion)
    Next
    
    Imports System
    Imports System.IO
    Imports System.Security
    Imports System.Text.RegularExpressions
    
    Namespace DotNetFramework
        Public Class SystemInfo
            Private Const FRAMEWORK_PATH As String = "\Microsoft.NET\Framework"
            Private Const WINDIR1 As String = "windir"
            Private Const WINDIR2 As String = "SystemRoot"
            Private _versions As New Collection
    
            Public ReadOnly Property FrameworkVersions() As Collection
                Get
                    Try
                        GetVersions(NetFrameworkInstallationPath)
                    Catch e1 As SecurityException
                        Return Nothing
                    End Try
                    Return _versions
                End Get
            End Property
    
            Public ReadOnly Property HighestFrameworkVersion() As String
                Get
                    Try
                        Return GetHighestVersion(NetFrameworkInstallationPath)
                    Catch e1 As SecurityException
                        Return "Unknown"
                    End Try
                End Get
            End Property
    
            Private Sub GetVersions(ByVal installationPath As String)
    
                Dim versions() As String = Directory.GetDirectories(installationPath, "v*")
                Dim VersionNumber As String
                _versions.Clear()
    
                For i As Integer = versions.Length - 1 To 0 Step -1
                    VersionNumber = ExtractVersion(versions(i))
    
                    If IsFrameworkVersionFormat(VersionNumber) Then
                        _versions.Add(VersionNumber)
                    End If
                Next i
    
            End Sub
    
            Private Function GetHighestVersion(ByVal installationPath As String) As String
                Dim versions() As String = Directory.GetDirectories(installationPath, "v*")
                Dim version As String = "Unknown"
    
                For i As Integer = versions.Length - 1 To 0 Step -1
                    version = ExtractVersion(versions(i))
    
                    If IsFrameworkVersionFormat(version) Then
                        Return version
                    End If
                Next i
    
                Return version
            End Function
    
            Private Function ExtractVersion(ByVal directory As String) As String
                Dim startIndex As Integer = directory.LastIndexOf("\") + 2
                Return directory.Substring(startIndex, directory.Length - startIndex)
            End Function
    
            Private Shared Function IsFrameworkVersionFormat(ByVal str As String) As Boolean
                Return New Regex("^[0-9]+\.?[0-9]+\.?[0-9]*$").IsMatch(str)
            End Function
    
            Public ReadOnly Property NetFrameworkInstallationPath() As String
                Get
                    Return WindowsPath & FRAMEWORK_PATH
                End Get
            End Property
    
            Public ReadOnly Property WindowsPath() As String
                Get
                    Dim winDir As String = Environment.GetEnvironmentVariable(WINDIR1)
                    If String.IsNullOrEmpty(winDir) Then
                        winDir = Environment.GetEnvironmentVariable(WINDIR2)
                    End If
    
                    Return winDir
                End Get
            End Property
        End Class
    End Namespace
    Modify it to your needs

    (...sometimes I outdo myself....)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 00:47.
Find Us