This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,109 @@
using System;
using System.Diagnostics;
using Microsoft.Win32;
using System.Windows.Forms;
using RegAddProductCode.Properties;
namespace RegAddProductCode
{
class AddProductCode
{
private static EventLog log = new EventLog();
static int Main(string[] args)
{
var architectureVersion = string.Empty;
for (var i = 0; i < args.Length; i++)
{
switch (i)
{
case 0:
architectureVersion = args[i];
break;
}
}
log.Source = "DataPROInstaller";
log.WriteEntry("ArchitectureVersion is " + architectureVersion);
log.WriteEntry(!Environment.Is64BitProcess ? "This is NOT a 64-bit process" : "This IS a 64-bit process");
log.WriteEntry(Environment.Is64BitOperatingSystem ? "This IS a 64-bit operation system" : "This is NOT a 64-bit operating system");
switch (architectureVersion)
{
case "x86":
if (Environment.Is64BitOperatingSystem)
{
//Return false so the installer will terminate due to running the 32-bit installer
//on a 64-bit operating system. This would be OK, except that if the 32-bit 2014 SqlLocalDb
//installer needs to be installed as a prerequisite, it will fail silently and DataPRO
//will fail upon initiation due to a database with a higher version than what 2012 SqlLocalDb
//can handle.
log.WriteEntry("Displaying 32-bit error message box and returning 1");
MessageBox.Show("32-bit DataPRO is not allowed to be installed on 64-bit operating system");
return 1;
}
break;
case "x64":
if (!Environment.Is64BitOperatingSystem)
{
//Return false so the installer will gracefully terminate instead of less gracefully later.
log.WriteEntry("Displaying 64-bit error message box and returning 1");
MessageBox.Show("64-bit DataPRO is not allowed to be installed on 32-bit operating system");
return 1;
}
break;
}
log.WriteEntry("Calling AddCodeToRegistry");
var result = AddCodeToRegistry();
log.WriteEntry("Result of AddCodeToRegistry is " + result);
//if (!string.IsNullOrWhiteSpace(result))
//{
// MessageBox.Show(result);
//}
log.WriteEntry("Returning 0");
return 0;
}
/// <summary>
/// Ensures that the following is in the Registry:
/// Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer
/// and that it contains the following: Name: SecureRepairPolicy; Type: REG_DWORD; Data 0x00000002 (2)
/// Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer\SecureRepairWhitelist
/// and that it contains the following: Name: {C4889149-0CAF-44C1-B226-8F6E73684DF4}; Type: REG_DWORD; Data 0x00000000 (0)
/// so that the DataPRO.exe (or its dependents) may be installed.
/// </summary>
/// <returns></returns>
private static string AddCodeToRegistry()
{
var result = string.Empty;
try
{
var rk = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
var sk1 = rk.OpenSubKey(Settings.Default.InstallerKey, RegistryKeyPermissionCheck.ReadWriteSubTree,
System.Security.AccessControl.RegistryRights.FullControl);
if (sk1 == null) return string.Format(Settings.Default.MissingKey, Settings.Default.InstallerKey);
sk1.SetValue(Settings.Default.SecureRepairPolicy, 2, RegistryValueKind.DWord);
sk1 = rk.OpenSubKey(Settings.Default.SecureRepairWhitelistKey,
RegistryKeyPermissionCheck.ReadWriteSubTree,
System.Security.AccessControl.RegistryRights.FullControl) ??
Registry.LocalMachine.CreateSubKey(Settings.Default.SecureRepairWhitelistKey);
if (sk1 == null) return string.Format(Settings.Default.MissingKey, Settings.Default.SecureRepairWhitelistKey);
//Add this Product Code
sk1.SetValue(Settings.Default.ProductCode, 0);
}
catch (Exception ex)
{
result = ex.Message;
}
if (!string.IsNullOrWhiteSpace(result))
{
MessageBox.Show(result);
}
return result;
}
}
}

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="RegAddProductCode.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<applicationSettings>
<RegAddProductCode.Properties.Settings>
<setting name="InstallerKey" serializeAs="String">
<value>SOFTWARE\\Policies\\Microsoft\\Windows\\Installer</value>
</setting>
<setting name="MissingKey" serializeAs="String">
<value>No key at {0}</value>
</setting>
<setting name="ProductCode" serializeAs="String">
<value>{C4889149-0CAF-44C1-B226-8F6E73684DF4}</value>
</setting>
<setting name="SecureRepairPolicy" serializeAs="String">
<value>SecureRepairPolicy</value>
</setting>
<setting name="SecureRepairWhitelistKey" serializeAs="String">
<value>SOFTWARE\\Policies\\Microsoft\\Windows\\Installer\\SecureRepairWhitelist</value>
</setting>
</RegAddProductCode.Properties.Settings>
</applicationSettings>
</configuration>

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RegAddProductCode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RegAddProductCode")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8620652f-f86e-466a-8d7b-d3088a7b0c05")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace RegAddProductCode.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("SOFTWARE\\\\Policies\\\\Microsoft\\\\Windows\\\\Installer")]
public string InstallerKey {
get {
return ((string)(this["InstallerKey"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("No key at {0}")]
public string MissingKey {
get {
return ((string)(this["MissingKey"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("{C4889149-0CAF-44C1-B226-8F6E73684DF4}")]
public string ProductCode {
get {
return ((string)(this["ProductCode"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("SecureRepairPolicy")]
public string SecureRepairPolicy {
get {
return ((string)(this["SecureRepairPolicy"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("SOFTWARE\\\\Policies\\\\Microsoft\\\\Windows\\\\Installer\\\\SecureRepairWhitelist")]
public string SecureRepairWhitelistKey {
get {
return ((string)(this["SecureRepairWhitelistKey"]));
}
}
}
}

View File

@@ -0,0 +1,21 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RegAddProductCode.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="InstallerKey" Type="System.String" Scope="Application">
<Value Profile="(Default)">SOFTWARE\\Policies\\Microsoft\\Windows\\Installer</Value>
</Setting>
<Setting Name="MissingKey" Type="System.String" Scope="Application">
<Value Profile="(Default)">No key at {0}</Value>
</Setting>
<Setting Name="ProductCode" Type="System.String" Scope="Application">
<Value Profile="(Default)">{C4889149-0CAF-44C1-B226-8F6E73684DF4}</Value>
</Setting>
<Setting Name="SecureRepairPolicy" Type="System.String" Scope="Application">
<Value Profile="(Default)">SecureRepairPolicy</Value>
</Setting>
<Setting Name="SecureRepairWhitelistKey" Type="System.String" Scope="Application">
<Value Profile="(Default)">SOFTWARE\\Policies\\Microsoft\\Windows\\Installer\\SecureRepairWhitelist</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8620652F-F86E-466A-8D7B-D3088A7B0C05}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>RegAddProductCode</RootNamespace>
<AssemblyName>RegAddProductCode</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AddProductCode.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = "")]

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]