Initial check-in

This commit is contained in:
Duc
2025-03-13 18:24:10 -07:00
parent 221aac70bb
commit 738834be94
57 changed files with 28548 additions and 20 deletions

63
.gitattributes vendored Normal file
View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

377
.gitignore vendored
View File

@@ -1,26 +1,363 @@
# ---> Windows
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# Dump file
*.stackdump
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# Folder config file
[Dd]esktop.ini
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Mono auto generated files
mono_crash.*
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Oo]ut/
[Ll]og/
[Ll]ogs/
# Windows shortcuts
*.lnk
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUnit
*.VisualState.xml
TestResult.xml
nunit-*.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# NuGet Symbol Packages
*.snupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
*.appxbundle
*.appxupload
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

View File

@@ -0,0 +1,211 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{8EFC377F-70B4-468B-BF30-B637C5857AA7}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>All_Purpose_Auto_Setup</RootNamespace>
<AssemblyName>All_Purpose_Auto_Setup</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<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>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>sm3_setup.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</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>
<ItemGroup>
<Reference Include="CommonLib">
<HintPath>DLL\CommonLib.dll</HintPath>
</Reference>
<Reference Include="JetBrains.Annotations">
<HintPath>packages\TaskScheduler.2.5.28\lib\net40\JetBrains.Annotations.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Win32.TaskScheduler">
<HintPath>packages\TaskScheduler.2.5.28\lib\net40\Microsoft.Win32.TaskScheduler.dll</HintPath>
<Aliases>TaskSchedulerAlias</Aliases>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConfigFileManager.cs" />
<Compile Include="DotNet2Pt0FrameworkManager.cs" />
<Compile Include="FileFolderRemovalManager.cs" />
<Compile Include="FilePackageTransferManager.cs" />
<Compile Include="frmAbout.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmAbout.Designer.cs">
<DependentUpon>frmAbout.cs</DependentUpon>
</Compile>
<Compile Include="frmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmMain.Designer.cs">
<DependentUpon>frmMain.cs</DependentUpon>
</Compile>
<Compile Include="frmSetupStatusDisplay.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmSetupStatusDisplay.Designer.cs">
<DependentUpon>frmSetupStatusDisplay.cs</DependentUpon>
</Compile>
<Compile Include="FoldersManager.cs" />
<Compile Include="frmUserInput.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmUserInput.Designer.cs">
<DependentUpon>frmUserInput.cs</DependentUpon>
</Compile>
<Compile Include="NetworkAdapterManager.cs" />
<Compile Include="RunApplicationsManager.cs" />
<Compile Include="SetupMiscellaneous.cs" />
<Compile Include="GutsSoftwareBuildAssistant.cs" />
<Compile Include="GutsConfigFileManager.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Common.cs" />
<Compile Include="SoftwareInstallManager.cs" />
<Compile Include="WindowFeaturesManager.cs" />
<Compile Include="WindowsRegistryManager.cs" />
<Compile Include="WindowsShortcutManager.cs" />
<EmbeddedResource Include="frmAbout.resx">
<DependentUpon>frmAbout.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="frmMain.resx">
<DependentUpon>frmMain.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="frmSetupStatusDisplay.resx">
<DependentUpon>frmSetupStatusDisplay.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmUserInput.resx">
<DependentUpon>frmUserInput.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.manifest" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="sm3_setup.ico" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\sm3missile.jpg" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</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" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34408.163
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "All_Purpose_Auto_Setup", "All_Purpose_Auto_Setup.csproj", "{8EFC377F-70B4-468B-BF30-B637C5857AA7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Debug|x64.ActiveCfg = Debug|x64
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Debug|x64.Build.0 = Debug|x64
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Release|Any CPU.Build.0 = Release|Any CPU
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Release|x64.ActiveCfg = Release|x64
{8EFC377F-70B4-468B-BF30-B637C5857AA7}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D478406A-C7B7-40FA-9C5B-9CD4D5AB67F1}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="All_Purpose_Automated_Windows_Setup.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<userSettings>
<All_Purpose_Automated_Windows_Setup.Properties.Settings>
<setting name="ConfigFile" serializeAs="String">
<value/>
</setting>
<setting name="AutoRunOnStartup" serializeAs="String">
<value>False</value>
</setting>
<setting name="CurrentSetupStep" serializeAs="String">
<value>-1</value>
</setting>
</All_Purpose_Automated_Windows_Setup.Properties.Settings>
</userSettings>
</configuration>

View File

@@ -0,0 +1,339 @@
// this alias is used for Microsoft.Win32.TaskScheduler.dll because
// this dll defines the same type in the same namespace as the one defined in
// mscorlib.dll, mainly namespace of System.Collection.Generic, and types: IReadOnlyList, IReadOnlyCollection.
// By using this alias this the TaskScheduler dll, we avoid the
// warning of conflict of the same type in the same namespace being defined in
// more than one assemblies.
extern alias TaskSchedulerAlias;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using System.Windows.Forms;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
using CommonLib.Windows.Misc;
namespace All_Purpose_Auto_Setup
{
class Common
{
delegate string GetWindowPathDelegate();
static Dictionary<string, GetWindowPathDelegate> getWindowPathDel = new Dictionary<string, GetWindowPathDelegate>(StringComparer.OrdinalIgnoreCase)
{ { PathManip.enumWindowsDesignatedPaths.USER_DESKTOP.ToString(), PathManip.GetUserDesktopPath},
{ PathManip.enumWindowsDesignatedPaths.USER_PROFILE.ToString(), PathManip.GetUserProfilePath},
{ PathManip.enumWindowsDesignatedPaths.ALL_USER_DESKTOP.ToString(), PathManip.GetAllUserDesktopPath},
{ PathManip.enumWindowsDesignatedPaths.USER_STARTUP_FOLDER.ToString(), PathManip.GetUserStartupFolderPath},
{ PathManip.enumWindowsDesignatedPaths.ALL_USER_STARTUP_FOLDER.ToString(), PathManip.GetAllUserStartupFolderPath},
{ PathManip.enumWindowsDesignatedPaths.USER_TEMP_FOLDER.ToString(), PathManip.GetUserTempPath}
};
public enum enum_SETUP_STEPS
{
NOT_VALID_STEP, // for initialization purposes
INSTALL_SOFTWARE_PACKAGES,
ENABLE_INTERNET_INFORMATION_SERVICES,
CREATE_DIRECTORIES,
CREATE_NETWORK_SHARES,
SET_ENVIRONMENT_VARIABLES,
SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS,
PROCESS_GUTS_CONFIG_FILE,
CREATE_WINDOWS_SHORTCUTS,
ASSIST_BUILDING_GUTS_APP,
TRANSFER_FILE_PACKAGES,
REMOVE_FILES_FOLDERS,
RUN_APPLICATIONS,
MODIFY_WINDOWS_REGISTRY,
CONFIGURE_NETWORK_ADAPTERS,
PROMPT_USER
}
public enum EXECUTION_STATUS
{
SUCCESS,
FAILURE,
SYSTEM_SKIP,
USER_SKIP // user decides to skip execution, in which cas, the action is neither successful or failed
}
public static bool pathContainsMacro(string path)
{
bool pathHasMacro = false;
foreach (PathManip.enumWindowsDesignatedPaths winPath in Enum.GetValues(typeof(PathManip.enumWindowsDesignatedPaths)))
{
string pattern = @"^\{" + winPath.ToString() + @"\}.*";
if (Regex.IsMatch(path, pattern, RegexOptions.IgnoreCase))
{
pathHasMacro = true;
break;
}
}
return pathHasMacro;
}
public static bool pathContainsCdDriveMacro(string path)
{
bool pathHasCdMacro = false;
Match regExMatch = Regex.Match(path, @"^\{([^\{\}]+)\}.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
if (String.Equals(regExMatch.Groups[1].Value, PathManip.enumWindowsDesignatedPaths.CD_DRIVE.ToString(), StringComparison.OrdinalIgnoreCase))
pathHasCdMacro = true;
}
return pathHasCdMacro;
}
public static string resolveMacroPath(string path)
{
string resolvedPath = path;
Match regExMatch;
regExMatch = Regex.Match(path, @"^\{([^\{\}]+)\}.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
if (getWindowPathDel.ContainsKey(regExMatch.Groups[1].Value))
{
resolvedPath = Regex.Replace(path, @"\{([^\{\}]+)\}", getWindowPathDel[regExMatch.Groups[1].Value].Invoke(), RegexOptions.IgnoreCase);
}
// if cd drive macro is define then we have to process it a little bit differently, since there can be multiple cd drives in the system
else if (String.Equals(PathManip.enumWindowsDesignatedPaths.CD_DRIVE.ToString(), regExMatch.Groups[1].Value, StringComparison.OrdinalIgnoreCase))
{
resolvedPath = getValidatedCdPath(path);
}
}
return resolvedPath;
}
public static bool validatePathInCdDrive(string path, Form parentForm)
{
bool successful = true;
string msg = "";
DriveInfo drive = new DriveInfo(path.Substring(0, 1));
while (!drive.IsReady || (!File.Exists(path) && !Directory.Exists(path)))
{
Hardware.OpenCdDrive(drive.Name);
msg = ((frmSetupStatusDisplay)parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.OKCANCEL, null, "Please insert a disc into drive "
+ drive.Name + " that has the following path:\n" + path + "\n\n Click OK to proceed", "Info", -1);
if (String.Equals(msg, "cancel", StringComparison.OrdinalIgnoreCase))
{
successful = false;
break;
}
}
return successful;
}
// if user specifies a path with a cd drive prefix macro (i.e. {cd_drive}\hey.txt, then we want to find the cd drive with the path (file or directory) specified
public static string getValidatedCdPath(string path = "")
{
string cdPath = "";
string emptyDrivePath = "";
List<string> cdDrives = Hardware.GetAllCdDrives();
foreach (string drive in cdDrives)
{
if (path.Length == 0)
{
cdPath = drive;
break;
}
else
{
string tempPath = Regex.Replace(path, @"\{([^\{\}]+)\}", PathManip.RemoveTrailingSlashInPath(drive), RegexOptions.IgnoreCase);
DriveInfo driveInfo = new DriveInfo(tempPath.Substring(0, 1));
if (File.Exists(tempPath) || Directory.Exists(tempPath))
{
cdPath = tempPath;
break;
}
else if (!driveInfo.IsReady && emptyDrivePath.Length == 0)
{
emptyDrivePath = tempPath;
}
}
}
if (cdPath.Length == 0 && cdDrives.Count > 0)
{
if (emptyDrivePath.Length > 0)
cdPath = emptyDrivePath;
else
cdPath = Regex.Replace(path, @"\{([^\{\}]+)\}", PathManip.RemoveTrailingSlashInPath(cdDrives[0]), RegexOptions.IgnoreCase);
}
return cdPath;
}
// return indentation in spaces
public static string getIndentation(int indentMultiples)
{
string indentUnit = " ";
string indentation = String.Empty;
for (int i = 1; i <= indentMultiples; i++)
indentation += indentUnit;
return indentation;
}
public static Color getSetupStatusColor(EXECUTION_STATUS status)
{
if (status == EXECUTION_STATUS.SUCCESS)
return Color.Green;
else if (status == EXECUTION_STATUS.FAILURE)
return Color.Red;
else
return Color.FromArgb(224, 154, 14);
}
public static Color getSetupStepTitleColor()
{
return Color.FromArgb(125, 143, 128);
}
public static void formatConfigIniFailureMessage(string message, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList)
{
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.textColor = getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 10);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(message, "File:");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(message, "Section:");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
if (StringManip.GetPhraseWordIndexInText(message, "Key:") > -1)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(message, "Key:");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
if (StringManip.GetPhraseWordIndexInText(message, "Value:") > -1)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(message, "Value:");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(message, "Description:") - 1;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
public static void enableAutoRunAfterReboot(string taskSchedulerName, string appPath)
{
Properties.Settings.Default["AutoRunOnStartup"] = true;
createTaskSchedulerForAutoRunAfterReboot(taskSchedulerName, appPath);
}
private static void createTaskSchedulerForAutoRunAfterReboot(string taskSchedulerName, string appPath)
{
using (TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.TaskService ts = new TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.TaskService())
{
if (ts.GetTask(taskSchedulerName) == null)
{
TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = taskSchedulerName;
// when running task, use the following account
td.Principal.UserId = String.Concat(Environment.UserDomainName, "\\", Environment.UserName);
// only run after user has logged on
td.Principal.LogonType = TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.TaskLogonType.InteractiveToken;
// run this task with highest privileges
td.Principal.RunLevel = TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.TaskRunLevel.Highest;
// creating the trigger, this actually executes the task
TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.LogonTrigger trigger = new TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.LogonTrigger();
trigger.UserId = String.Concat(Environment.UserDomainName, "\\", Environment.UserName);
trigger.Delay = TimeSpan.FromSeconds(60.0);
td.Triggers.Add(trigger);
td.Actions.Add(new TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.ExecAction(appPath, null, null));
ts.RootFolder.RegisterTaskDefinition(taskSchedulerName, td);
}
}
}
public static void deleteTaskSchedulerForAutoRunAfterReboot(string taskSchedulerName)
{
using (TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.TaskService ts = new TaskSchedulerAlias::Microsoft.Win32.TaskScheduler.TaskService())
{
if (ts.GetTask(taskSchedulerName) != null)
{
ts.RootFolder.DeleteTask(taskSchedulerName);
}
}
}
}
}

View File

@@ -0,0 +1,502 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class ConfigFileManager
{
// each of the enumeration in here should match a section name in the INI file
public enum enum_INI_SECTION_NAMES
{
General,
Global_Settings,
GUTS_Info,
Install_Software,
Paths_Creation,
Paths_Sharing,
Env_Variables,
Setup_Step_Manager,
GUTS_Pre_Build_Assistance,
Files_Transfer_Packages,
GUTS_Config_File,
Windows_Shortcuts,
Files_Folders_Removal,
Run_Applications,
Windows_Features,
Windows_Registry
}
// this is used to verify INI file and flag errors in the INI file for user to fix
public struct Ini_KeyValue<T>
{
public string iniSectionName;
public string iniKeyName;
public string iniValue;
public T alternateValue; // user-defined value, this could be a bool, int, anything
public Ini_KeyValue(T tvar)
{
iniSectionName = String.Empty;
iniKeyName = String.Empty;
iniValue = String.Empty;
alternateValue = tvar;
}
}
public struct ConfigGeneralInfo
{
public IniFileManip iniFile;
public string pathAndNameOfConfigFile;
public bool is64BitPlatform;
public bool is32BitPlatform;
public Ini_KeyValue<string> programName;
public Ini_KeyValue<string> applicationPlatform;
}
public struct ConfigGlobalSettings
{
public Ini_KeyValue<bool> suppressAllPrompts;
}
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
//public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
Form m_parentForm;
public static ConfigGeneralInfo ms_configGeneralInfo;
public static ConfigGlobalSettings ms_configGlobalSettings;
public ConfigFileManager(Form parentForm, string configFile)
{
m_parentForm = parentForm;
ms_configGeneralInfo.pathAndNameOfConfigFile = configFile;
ms_configGeneralInfo.programName = new Ini_KeyValue<string>("");
ms_configGeneralInfo.applicationPlatform = new Ini_KeyValue<string>("");
ms_configGeneralInfo.is32BitPlatform = false;
ms_configGeneralInfo.is64BitPlatform = false;
ms_configGeneralInfo.iniFile = new IniFileManip(ms_configGeneralInfo.pathAndNameOfConfigFile);
ms_configGlobalSettings.suppressAllPrompts = new Ini_KeyValue<bool>(false);
parseConfigInfo();
}
private void parseConfigInfo()
{
readGeneralSection(ms_configGeneralInfo.iniFile);
readGlobalSection(ms_configGeneralInfo.iniFile);
}
public static void parseConfigInfo(string iniSectionName, List<Ini_KeyValue<string>> configInfo)
{
string[] keyDataPair;
string[] sectionData;
Ini_KeyValue<string> iniVal = new Ini_KeyValue<string>("");
if (configInfo == null)
configInfo = new List<Ini_KeyValue<string>>();
sectionData = ms_configGeneralInfo.iniFile.ReadSectionData(iniSectionName);
foreach (string line in sectionData)
{
keyDataPair = line.Split('=');
if (keyDataPair.Length == 2)
{
iniVal.iniSectionName = iniSectionName;
iniVal.iniKeyName = keyDataPair[0];
iniVal.iniValue = keyDataPair[1];
configInfo.Add(iniVal) ;
}
}
}
public static void parseConfigInfo(string iniSectionName, Dictionary<string,string> configInfo)
{
string[] keyDataPair;
string[] sectionData;
if (configInfo == null)
configInfo = new Dictionary<string,string>();
sectionData = ms_configGeneralInfo.iniFile.ReadSectionData(iniSectionName);
foreach (string line in sectionData)
{
keyDataPair = line.Split('=');
if (keyDataPair.Length == 2)
configInfo[keyDataPair[0]] = keyDataPair[1];
}
}
public void readGeneralSection(IniFileManip iniFile)
{
string[] keyDataPair;
Dictionary<string, string> keyAndValuePair = new Dictionary<string, string>();
Dictionary<string, string> keyAndValuePair2 = new Dictionary<string, string>();
Ini_KeyValue<bool> bIniVal = new Ini_KeyValue<bool>(false);
Ini_KeyValue<string> iniVal = new Ini_KeyValue<string>("");
Ini_KeyValue<string> iniVal2 = new Ini_KeyValue<string>("");
string sectionName;
string[] sectionData;
sectionName = enum_INI_SECTION_NAMES.General.ToString();
sectionData = iniFile.ReadSectionData(sectionName);
ms_configGeneralInfo.programName.iniKeyName = "program_name";
ms_configGeneralInfo.programName.iniSectionName = sectionName;
ms_configGeneralInfo.applicationPlatform.iniKeyName = "Application_Platform";
ms_configGeneralInfo.applicationPlatform.iniSectionName = sectionName;
foreach (string line in sectionData)
{
keyDataPair = line.Split('=');
if (String.Equals(keyDataPair[0], ms_configGeneralInfo.programName.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
if (keyDataPair.Length == 2)
{
ms_configGeneralInfo.programName.iniValue = keyDataPair[1];
}
}
else if (String.Equals(keyDataPair[0], ms_configGeneralInfo.applicationPlatform.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
if (keyDataPair.Length == 2)
{
ms_configGeneralInfo.applicationPlatform.iniValue = keyDataPair[1];
}
if (String.Equals(ms_configGeneralInfo.applicationPlatform.iniValue, "32", StringComparison.OrdinalIgnoreCase))
ms_configGeneralInfo.is32BitPlatform = true;
else if (String.Equals(ms_configGeneralInfo.applicationPlatform.iniValue, "64", StringComparison.OrdinalIgnoreCase))
ms_configGeneralInfo.is64BitPlatform = true;
else
ms_configGeneralInfo.is64BitPlatform = true;
}
}
}
public void readGlobalSection(IniFileManip iniFile)
{
string[] keyDataPair;
Dictionary<string, string> keyAndValuePair = new Dictionary<string, string>();
Dictionary<string, string> keyAndValuePair2 = new Dictionary<string, string>();
Ini_KeyValue<bool> bIniVal = new Ini_KeyValue<bool>(false);
Ini_KeyValue<string> iniVal = new Ini_KeyValue<string>("");
Ini_KeyValue<string> iniVal2 = new Ini_KeyValue<string>("");
string sectionName;
string[] sectionData;
sectionName = enum_INI_SECTION_NAMES.Global_Settings.ToString();
sectionData = iniFile.ReadSectionData(sectionName);
ms_configGlobalSettings.suppressAllPrompts.iniKeyName = "Suppress_All_Prompts";
ms_configGlobalSettings.suppressAllPrompts.iniSectionName = sectionName;
foreach (string line in sectionData)
{
keyDataPair = line.Split('=');
if (String.Equals(keyDataPair[0], ms_configGlobalSettings.suppressAllPrompts.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
if (keyDataPair.Length == 2)
{
ms_configGlobalSettings.suppressAllPrompts.iniValue = keyDataPair[1];
}
if (String.Equals(ms_configGlobalSettings.suppressAllPrompts.iniValue, "true", StringComparison.OrdinalIgnoreCase)
||
String.Equals(ms_configGlobalSettings.suppressAllPrompts.iniValue, "yes", StringComparison.OrdinalIgnoreCase))
ms_configGlobalSettings.suppressAllPrompts.alternateValue = true;
else
ms_configGlobalSettings.suppressAllPrompts.alternateValue = false;
}
}
}
public static void readOneToManyDictionary(IniFileManip iniFile, string sectionName, string leftDictPattern, string rightDictPattern, Dictionary<Ini_KeyValue<string>, List<Ini_KeyValue<string>>> dict)
{
string[] keyDataPair, splitStrings, splitStrings2;
Match regExMatch;
Dictionary<string, string> keyAndValuePair = new Dictionary<string, string>();
Dictionary<string, string> keyAndValuePair2 = new Dictionary<string, string>();
Ini_KeyValue<bool> bIniVal = new Ini_KeyValue<bool>(false);
Ini_KeyValue<string> iniVal = new Ini_KeyValue<string>("");
Ini_KeyValue<string> iniVal2 = new Ini_KeyValue<string>("");
string[] sectionData;
string iniEntryDelimiter = "[ini_entry_separator]";
string iniKeyValueDelimiter = "[key_value_separator]";
sectionData = iniFile.ReadSectionData(sectionName);
foreach (string line in sectionData)
{
keyDataPair = line.Split('=');
if (keyDataPair.Length == 2)
keyDataPair[1] = Regex.Replace(keyDataPair[1], @"\{equal_sign\}", "=");
regExMatch = Regex.Match(keyDataPair[0], leftDictPattern, RegexOptions.IgnoreCase);
// if item belongs to the left side of the dictionary
if (regExMatch.Success && keyDataPair.Length == 2)
{
// if there's not already an item that exists in the dictionary
if (!keyAndValuePair.ContainsKey(regExMatch.Groups[1].Value) && keyDataPair[1].Length > 0)
{
// generate the key information
iniVal.iniSectionName = sectionName;
iniVal.iniKeyName = keyDataPair[0];
iniVal.iniValue = keyDataPair[1];
// if there are items on the right of the dictionary that's associated with the item on the left side
if (keyAndValuePair2.ContainsKey(regExMatch.Groups[1].Value))
{
splitStrings = keyAndValuePair2[regExMatch.Groups[1].Value].Split(new string[] { iniEntryDelimiter }, StringSplitOptions.RemoveEmptyEntries);
foreach (string keyValuePairItem in splitStrings)
{
splitStrings2 = keyValuePairItem.Split(new string[] { iniKeyValueDelimiter }, StringSplitOptions.None);
// generate value information
iniVal2.iniSectionName = sectionName;
iniVal2.iniKeyName = splitStrings2[0];
iniVal2.iniValue = splitStrings2[1];
if (dict.ContainsKey(iniVal))
dict[iniVal].Add(iniVal2);
else
dict[iniVal] = new List<Ini_KeyValue<string>>() { iniVal2 };
if (!keyAndValuePair.ContainsKey(regExMatch.Groups[1].Value))
{
keyAndValuePair[regExMatch.Groups[1].Value] = keyDataPair[0] + iniKeyValueDelimiter + keyDataPair[1];
}
}
keyAndValuePair2.Remove(regExMatch.Groups[1].Value);
}
else // store the Ini struct of the left hand side of the dictionary
keyAndValuePair[regExMatch.Groups[1].Value] = keyDataPair[0] + iniKeyValueDelimiter + keyDataPair[1];
}
}
else
{
regExMatch = Regex.Match(keyDataPair[0], rightDictPattern, RegexOptions.IgnoreCase);
// if the item belong to the right side of the dictionary
if (regExMatch.Success && keyDataPair.Length == 2)
{
// is this key/value is associated with the corresponding value of the left hand side of the dictionary
if (keyAndValuePair.ContainsKey(regExMatch.Groups[1].Value))
{
// get the ini properties of the left side of the dictionary
splitStrings2 = keyAndValuePair[regExMatch.Groups[1].Value].Split(new string[] { iniKeyValueDelimiter }, StringSplitOptions.RemoveEmptyEntries);
// generate the key information
iniVal.iniSectionName = sectionName;
iniVal.iniKeyName = splitStrings2[0];
iniVal.iniValue = splitStrings2[1];
// generate value information
iniVal2.iniSectionName = sectionName;
iniVal2.iniKeyName = keyDataPair[0];
iniVal2.iniValue = keyDataPair[1];
// save the key/value for this app name
if (dict.ContainsKey(iniVal))
dict[iniVal].Add(iniVal2);
else
dict[iniVal] = new List<Ini_KeyValue<string>>() { iniVal2 };
}
else
{
if (keyAndValuePair2.ContainsKey(regExMatch.Groups[1].Value))
{
keyAndValuePair2[regExMatch.Groups[1].Value] += iniEntryDelimiter + keyDataPair[0] + iniKeyValueDelimiter + keyDataPair[1];
}
else
keyAndValuePair2[regExMatch.Groups[1].Value] = keyDataPair[0] + iniKeyValueDelimiter + keyDataPair[1];
}
}
}
}
if (keyAndValuePair.Count > 0)
{
// remove entries in keyAndValuePair that have already been saved in the dictionary
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in dict)
{
regExMatch = Regex.Match(entry.Key.iniKeyName, leftDictPattern, RegexOptions.IgnoreCase);
// if item belongs to the left side of the dictionary
if (regExMatch.Success)
{
if (keyAndValuePair.ContainsKey(regExMatch.Groups[1].Value))
keyAndValuePair.Remove(regExMatch.Groups[1].Value);
}
}
// for each group of items, if only the left side of the dictionary is defined, add it to the dictionary anyway
foreach (KeyValuePair<string, string> entry in keyAndValuePair)
{
// break down the elements of the left side of dictionary
splitStrings2 = entry.Value.Split(new string[] { iniKeyValueDelimiter }, StringSplitOptions.RemoveEmptyEntries);
// generate the key information
iniVal.iniSectionName = sectionName;
iniVal.iniKeyName = splitStrings2[0];
iniVal.iniValue = splitStrings2[1];
if (!dict.ContainsKey(iniVal))
dict[iniVal] = new List<Ini_KeyValue<string>>();
}
}
}
public void readOneToOneDictionary(IniFileManip iniFile, string sectionName, string leftDictPattern, string rightDictPattern, Dictionary<Ini_KeyValue<string>, Ini_KeyValue<string>> dict)
{
string[] keyDataPair, splitStrings2;
Match regExMatch;
Dictionary<string, string> keyAndValuePair = new Dictionary<string, string>();
Dictionary<string, string> keyAndValuePair2 = new Dictionary<string, string>();
Ini_KeyValue<bool> bIniVal = new Ini_KeyValue<bool>(false);
Ini_KeyValue<string> iniVal = new Ini_KeyValue<string>("");
Ini_KeyValue<string> iniVal2 = new Ini_KeyValue<string>("");
string[] sectionData;
sectionData = iniFile.ReadSectionData(sectionName);
foreach (string path in sectionData)
{
keyDataPair = path.Split('=');
if (keyDataPair.Length == 2)
keyDataPair[1] = Regex.Replace(keyDataPair[1], @"\{equal_sign\}", "=");
regExMatch = Regex.Match(keyDataPair[0], leftDictPattern, RegexOptions.IgnoreCase);
// if item belongs to the left side of the dictionary
if (regExMatch.Success && keyDataPair.Length == 2)
{
// if there's not an existing item already in the dictionary
if (!keyAndValuePair.ContainsKey(regExMatch.Groups[1].Value))
{
// if the item on the right side is associated to the item on the left side of the dictionary
if (keyAndValuePair2.ContainsKey(regExMatch.Groups[1].Value))
{
// generate the key information
iniVal.iniSectionName = sectionName;
iniVal.iniKeyName = keyDataPair[0];
iniVal.iniValue = keyDataPair[1];
splitStrings2 = keyAndValuePair2[regExMatch.Groups[1].Value].Split('|');
// generate the value information
iniVal2.iniSectionName = sectionName;
iniVal2.iniKeyName = splitStrings2[0];
iniVal2.iniValue = splitStrings2[1];
dict[iniVal] = iniVal2;
keyAndValuePair2.Remove(regExMatch.Groups[1].Value);
}
else
keyAndValuePair[regExMatch.Groups[1].Value] = keyDataPair[0] + "|" + keyDataPair[1];
}
}
regExMatch = Regex.Match(keyDataPair[0], rightDictPattern, RegexOptions.IgnoreCase);
// if item belongs to the right side of the dictionary
if (regExMatch.Success && keyDataPair.Length == 2)
{
// if item on the left is associated with the item on the right side of the dictionary
if (keyAndValuePair.ContainsKey(regExMatch.Groups[1].Value))
{
// get the ini properties of the left side of the dictionary
splitStrings2 = keyAndValuePair[regExMatch.Groups[1].Value].Split('|');
// generate the key information
iniVal.iniSectionName = sectionName;
iniVal.iniKeyName = splitStrings2[0];
iniVal.iniValue = splitStrings2[1];
// generate the value information
iniVal2.iniSectionName = sectionName;
iniVal2.iniKeyName = keyDataPair[0];
iniVal2.iniValue = keyDataPair[1];
// create a new entry in the dictionary
dict[iniVal] = iniVal2;
}
else
{
keyAndValuePair2[regExMatch.Groups[1].Value] = keyDataPair[0] + "|" + keyDataPair[1];
}
}
}
if (keyAndValuePair.Count > 0)
{
// remove entries in keyAndValuePair that have already been saved in the dictionary
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, ConfigFileManager.Ini_KeyValue<string>> entry in dict)
{
regExMatch = Regex.Match(entry.Key.iniKeyName, leftDictPattern, RegexOptions.IgnoreCase);
// if item belongs to the left side of the dictionary
if (regExMatch.Success)
{
if (keyAndValuePair.ContainsKey(regExMatch.Groups[1].Value))
keyAndValuePair.Remove(regExMatch.Groups[1].Value);
}
}
// for each group of items, if only the left side of the dictionary is defined, add it to the dictionary anyway
foreach (KeyValuePair<string, string> entry in keyAndValuePair)
{
// break down the elements of the left side of dictionary
splitStrings2 = entry.Value.Split('|');
// generate the key information
iniVal.iniSectionName = sectionName;
iniVal.iniKeyName = splitStrings2[0];
iniVal.iniValue = splitStrings2[1];
iniVal2.iniSectionName = "";
iniVal2.iniKeyName = "";
iniVal2.iniValue = "";
if (!dict.ContainsKey(iniVal))
dict[iniVal] = iniVal2;
}
}
}
}
}

Binary file not shown.

View File

@@ -0,0 +1,285 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class DotNet2Pt0FrameworkManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
Form m_parentForm;
private bool dotNetSecurityZoneSettingSuccessful;
public DotNet2Pt0FrameworkManager(Form parentForm)
{
m_parentForm = parentForm;
}
// modify trust levels for security zones
public bool adjustZoneSecurityForDotNetFrameWork2Pt0(string sectionName)
{
bool setupSuccessful = true;
string indentation = String.Empty, platformStr;
string dotNetFrameWork2_32bit_Path = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727";
string dotNetFrameWork2_64bit_Path = @"C:\Windows\Microsoft.NET\Framework64\v2.0.50727";
string dotNetFrameWork2_Bin_Path;
string caspolApp = String.Empty;
List<string> securityZoneNames = new List<string>() { "My_Computer_Zone", "LocalIntranet_Zone", "Internet_Zone", "Trusted_Zone", "Restricted_Zone" };
List<string> trustLevels = new List<string>() { "FullTrust", "LocalIntranet", "Internet", "Nothing" };
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
string msg;
if (ConfigFileManager.ms_configGeneralInfo.is32BitPlatform)
{
platformStr = "32-bit";
dotNetFrameWork2_Bin_Path = dotNetFrameWork2_32bit_Path;
}
else
{
platformStr = "64-bit";
dotNetFrameWork2_Bin_Path = dotNetFrameWork2_64bit_Path;
}
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Setting .NET Framework 2.0 (" + platformStr + ") Security Zone Trust Level=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
if (setupSuccessful)
{
caspolApp = dotNetFrameWork2_Bin_Path + "\\caspol.exe";
if (!Directory.Exists(dotNetFrameWork2_32bit_Path))
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. .NET Framework 2.0 (" + platformStr + ") is not installed.";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.ERROR, null, "Unable to detect the presence .NET Framework 2.0 (" + platformStr + ").\n\n Please install .NET Framework 2.0 before continuing...", "ERROR!!!", -1);
setupSuccessful = false;
}
else if (!File.Exists(caspolApp))
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. " + caspolApp + " not found.";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.ERROR, null, "Unable to detect the presence .NET Framework 2.0 (" + platformStr + ").\n\n Please install .NET Framework 2.0 before continuing...", "ERROR!!!", -1);
setupSuccessful = false;
}
else
{
dotNetSecurityZoneSettingSuccessful = false;
ProcessStartInfo cmdStartInfo = new ProcessStartInfo();
cmdStartInfo.FileName = @"C:\Windows\System32\cmd.exe";
cmdStartInfo.RedirectStandardOutput = true;
cmdStartInfo.RedirectStandardError = true;
cmdStartInfo.RedirectStandardInput = true;
cmdStartInfo.UseShellExecute = false;
cmdStartInfo.CreateNoWindow = true;
Process cmdProcess;
//cmdProcess.StandardInput.WriteLine("Dism /online /disable-feature /featurename:IIS-FTPSvc /norestart"); //Execute command
cmdProcess = new Process();
cmdProcess.StartInfo = cmdStartInfo;
cmdProcess.ErrorDataReceived += cmd_Error;
cmdProcess.OutputDataReceived += cmd_SecurityZone_DataReceived;
cmdProcess.EnableRaisingEvents = true;
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
cmdProcess.BeginErrorReadLine();
// turn prompts off
cmdProcess.StandardInput.WriteLine(caspolApp + " -pp off"); //Execute command
cmdProcess.StandardInput.WriteLine("exit"); //Execute exit.
cmdProcess.WaitForExit();
cmdProcess.Close();
if (!dotNetSecurityZoneSettingSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. Access denied from running .NET Framework Caspol 2.0.";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.ERROR, null, "Access denied from running .NET Framework Caspol 2.0.\n\n Make sure to run application as Administrator...", "ERROR!!!", -1);
setupSuccessful = false;
}
foreach (string zone in securityZoneNames)
{
cmdProcess = new Process();
cmdProcess.StartInfo = cmdStartInfo;
cmdProcess.ErrorDataReceived += cmd_Error;
cmdProcess.OutputDataReceived += cmd_SecurityZone_DataReceived;
cmdProcess.EnableRaisingEvents = true;
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
cmdProcess.BeginErrorReadLine();
dotNetSecurityZoneSettingSuccessful = false;
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "" + zone + "=" + trustLevels[0];
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set trust level for security zone
cmdProcess.StandardInput.WriteLine(caspolApp + " -m -cg " + zone + " " + trustLevels[0]); //Execute command
//cmdProcess.StandardInput.WriteLine("");
//count++;
cmdProcess.StandardInput.WriteLine("exit"); //Execute exit.
cmdProcess.WaitForExit();
cmdProcess.Close();
if (dotNetSecurityZoneSettingSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = " - FAILED";
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
cmdProcess = new Process();
cmdProcess.StartInfo = cmdStartInfo;
//cmdProcess.ErrorDataReceived += cmd_Error;
//cmdProcess.OutputDataReceived += cmd_SecurityZone_DataReceived;
cmdProcess.EnableRaisingEvents = true;
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
cmdProcess.BeginErrorReadLine();
// turn policy change prompt back on. THIS IS VERY IMPORTANT
// if this is not turned back on, the Windows Firewall might block some functionality of an application
cmdProcess.StandardInput.WriteLine(caspolApp + " -pp on"); //Execute command
cmdProcess.StandardInput.WriteLine("exit"); //Execute exit.
cmdProcess.WaitForExit();
cmdProcess.Close();
}
}
return setupSuccessful;
}
void cmd_SecurityZone_DataReceived(object sender, DataReceivedEventArgs e)
{
Match regExMatch;
if (e.Data == null)
{
return;
}
regExMatch = Regex.Match(e.Data, @".*success.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
dotNetSecurityZoneSettingSuccessful = true;
}
}
void cmd_Error(object sender, DataReceivedEventArgs e)
{
//Console.WriteLine("Error from other process");
//Console.WriteLine(e.Data);
}
}
}

View File

@@ -0,0 +1,350 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using System.Xml;
using System.Xml.XPath;
using System.Net;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class FileFolderRemovalManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
public event Action<string, int, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAtLine;
public List<ConfigFileManager.Ini_KeyValue<bool>> filesFoldersToBeRemoved = new List<ConfigFileManager.Ini_KeyValue<bool>>();
Form m_parentForm;
public FileFolderRemovalManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool removeFilesFolders(string sectionName)
{
bool setupSuccessful = true;
string msg, indentation = String.Empty, displayMsg = "", logMsg = "";
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 10;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Removing Files/Folders=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
filesFoldersToBeRemoved.Clear();
parseConfigInfo(sectionName);
if (setupSuccessful)
{
int filesDeletedCount = 0, foldersDeletedCount = 0, filesSkipped = 0, foldersSkipped = 0;
frmSetupStatusDisplay displayFrm = (frmSetupStatusDisplay)m_parentForm;
int itemCountLineIndex = displayFrm.updateStatusDisplayAndLog("\n ", "", textPropList);
int deleteItemLineIndex = displayFrm.updateStatusDisplayAndLog("\n ", "", textPropList);
List<string> filesAndFoldersToBeRemoved = new List<string>();
foreach (ConfigFileManager.Ini_KeyValue<bool> item in filesFoldersToBeRemoved)
{
string path = "";
path = Path.GetFullPath(Common.resolveMacroPath(item.iniValue));
if (File.Exists(path))
{
filesAndFoldersToBeRemoved.Add(path);
}
else if (Directory.Exists(path))
{
// delete folder recursively
if (item.alternateValue)
{
filesAndFoldersToBeRemoved.Add(path);
}
else
{
string[] files = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly);
filesAndFoldersToBeRemoved.AddRange(files.ToList());
}
}
else
{
string what = "";
if (PathManip.PathIsFile(path))
{
filesSkipped++;
what = "File";
}
else
{
foldersSkipped++;
what = "Folder";
}
indentation = Common.getIndentation(1);
logMsg = "\n" + indentation + "Deleting " + path + " - SKIPPED. " + what + " does not exist";
UpdateStatusDisplayAndLogEvent("", logMsg, textPropList);
}
}
foreach (string item in filesAndFoldersToBeRemoved)
{
indentation = Common.getIndentation(1);
msg = indentation + "Files Deleted: " + filesDeletedCount.ToString() + " Folders Deleted: " + foldersDeletedCount.ToString();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = 2;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 10, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "Folders deleted:");
textProp.wordCount = 2;
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "Folders deleted:") + 2;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 10, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAtLine(msg, itemCountLineIndex, textPropList);
//tempTextPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>(textPropList);
if (File.Exists(item) || Directory.Exists(item))
{
displayMsg = indentation + "Deleting " + StringManip.ShortenStringToSize(item, 65);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
//textProp.textColor = Color.FromArgb(157, 150, 19);
textProp.wordIndex = 0;
textProp.wordCount = 1;
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(255, 60, 0);
textProp.wordIndex = 1;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAtLine(displayMsg, deleteItemLineIndex, textPropList);
if (Directory.Exists(item))
{
try
{
PathManip.DeleteFoldersRecursive(item);
foldersDeletedCount++;
logMsg = "\n" + indentation + "Deleting " + item + " - SUCCESS";
}
catch (Exception e)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
displayMsg = "\n" + indentation + "- FAILED. Error deleting folder\n" + indentation + "Folder: " + item + "\n" + indentation + "Error description: " + e.Message;
logMsg = "\n" + indentation + "Deleting " + item + " - FAILED";
setupSuccessful = false;
}
}
else
{
try
{
File.SetAttributes(item, FileAttributes.Normal);
File.Delete(item);
filesDeletedCount++;
logMsg = "\n" + indentation + "Deleting " + item + " - SUCCESS";
}
catch (Exception e)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
displayMsg = "\n" + indentation + "- FAILED. Error deleting file\n" + indentation + "File: " + item + "\n" + indentation + "Error description: " + e.Message;
logMsg = "\n" + indentation + "Deleting " + item + " - FAILED";
setupSuccessful = false;
}
}
if (!setupSuccessful)
{
break;
}
UpdateStatusDisplayAndLogEvent("", logMsg, textPropList);
}
Thread.Sleep(2000);
}
// delete the very first line that is the start of the progress update
// all the lines below the first starting lines will get deleted too
for (int i = 1; i <= 2; i++)
{
displayFrm.removeStatusDisplayLine(itemCountLineIndex, true);
}
if (!setupSuccessful)
{
UpdateStatusDisplayAndLogEvent(displayMsg, logMsg, textPropList);
}
if (setupSuccessful)
{
if (filesFoldersToBeRemoved.Count == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. No file/folder to delete";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SUCCESS. (Files Deleted: " + filesDeletedCount + " ) (Folders Deleted: " + foldersDeletedCount + " )" + " (Files skipped: " + filesSkipped + " )" + " (Folders skipped: " + foldersSkipped + " )";
UpdateStatusDisplayAndLogEvent(msg, "", textPropList);
}
}
msg = "\n" + Common.getIndentation(1) + "Files Deleted: " + filesDeletedCount + " | Folders Deleted: " + foldersDeletedCount + " | Files Skipped: " + filesSkipped + " | Folders Skipped: " + foldersSkipped;
UpdateStatusDisplayAndLogEvent("", msg, textPropList);
}
return setupSuccessful;
}
private void parseConfigInfo(string sectionName)
{
string[] keyDataPair;
Match regExMatch;
ConfigFileManager.Ini_KeyValue<bool> bIniVal = new ConfigFileManager.Ini_KeyValue<bool>(false);
string[] sectionData;
sectionData = ConfigFileManager.ms_configGeneralInfo.iniFile.ReadSectionData(sectionName);
foreach (string path in sectionData)
{
keyDataPair = path.Split('=');
if (keyDataPair.Length == 2)
{
bIniVal.iniSectionName = sectionName;
bIniVal.iniKeyName = keyDataPair[0];
bIniVal.iniValue = keyDataPair[1];
regExMatch = Regex.Match(bIniVal.iniValue, @"^([^,]+),.*recursive.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
bIniVal.alternateValue = true;
bIniVal.iniValue = regExMatch.Groups[1].Value;
}
else
bIniVal.alternateValue = false;
filesFoldersToBeRemoved.Add(bIniVal);
}
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,501 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.Windows.Misc;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class FoldersManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
public List<ConfigFileManager.Ini_KeyValue<string>> dirsToCreate = new List<ConfigFileManager.Ini_KeyValue<string>>();
// this dictionary stores path and its associated share names
// it would look like this:
// [ path1 ] -> List[sharenames accounts_to_share]
// [ path2 ] -> List[sharenames accounts_to_share]
public Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> pathAndShareNames = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
Form m_parentForm;
public FoldersManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool shareFolders(string sectionName)
{
string indentation = String.Empty;
bool setupSuccessful = true;
string msg, errorMsg = "";
ConfigFileManager.Ini_KeyValue<string> iniVal = new ConfigFileManager.Ini_KeyValue<string>("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Configuring network shares=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
pathAndShareNames.Clear();
ConfigFileManager.readOneToManyDictionary(ConfigFileManager.ms_configGeneralInfo.iniFile,
sectionName, @"(path\d+)$", @"(path\d+)[^\d].+$", pathAndShareNames);
setupSuccessful = verifyNetworkSharesInfo();
if (setupSuccessful)
{
if (pathAndShareNames.Count == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. Nothing to share";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in pathAndShareNames)
{
int autoShareNameKeyIndex = entry.Value.FindIndex(x => Regex.IsMatch(x.iniKeyName, @"auto-generated", RegexOptions.IgnoreCase));
int shareNameKeyIndex = entry.Value.FindIndex(x => Regex.IsMatch(x.iniKeyName, @"path\d+_additional.+", RegexOptions.IgnoreCase));
int allowedAccountKeyIndex = entry.Value.FindIndex(x => Regex.IsMatch(x.iniKeyName, @"path\d+_allowed.+", RegexOptions.IgnoreCase));
List<string> accounts = new List<string>();
List<string> shareNames = new List<string>();
if (allowedAccountKeyIndex >= 0)
{
accounts = new List<string>(entry.Value[allowedAccountKeyIndex].iniValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
}
if (accounts.Count == 0)
{
accounts.Add("Everyone");
}
if (shareNameKeyIndex >= 0)
{
shareNames = new List<string>(entry.Value[shareNameKeyIndex].iniValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
}
else if (autoShareNameKeyIndex >= 0)
{
shareNames = new List<string>(entry.Value[autoShareNameKeyIndex].iniValue.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries));
}
foreach (string name in shareNames)
{
string nameFormatted = name.Trim();
if (nameFormatted.Length == 1)
nameFormatted = nameFormatted.ToUpper();
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Sharing " + entry.Key.iniValue + " as " + nameFormatted;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "sharing") + 1;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg, "as") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
if (Directory.Exists("\\\\" + Environment.MachineName + '\\' + nameFormatted))
{
msg += " - SKIPPED. Share name already exists";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SKIPPED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "as") + 1;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg, "- skipped.") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
setupSuccessful = NetworkSharing.EnableNetworkFolderSharing(entry.Key.iniValue, nameFormatted, "", ref errorMsg);
if (!setupSuccessful)
{
msg += " - FAILED. " + errorMsg;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "as") + 1;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg, "- failed.") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "as") + 1;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg, "- success.") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
foreach (string account in accounts)
{
string accountFormatted = account.Trim();
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Giving account " + accountFormatted + " Full Permission to network share " + nameFormatted;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "giving account") + 2;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg, "full permission") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = NetworkSharing.addAccountToNetworkShare(entry.Key.iniValue, nameFormatted, accountFormatted, "", ref errorMsg);
if (!setupSuccessful)
{
msg += " - FAILED. " + errorMsg;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "network share") + 2;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg, "- failed.") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "network share") + 2;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg, "- success.") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
if (!setupSuccessful)
break;
}
if (!setupSuccessful)
break;
}
}
}
return setupSuccessful;
}
bool verifyNetworkSharesInfo()
{
bool setupSuccessful = true;
ConfigFileManager.Ini_KeyValue<string> iniVal = new ConfigFileManager.Ini_KeyValue<string>("");
string indentation = String.Empty;
string msg, str;
string[] splitStrings;
Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> tempOneToManyDict = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// for every folder to be shared, extract the folder name and use it as a share name
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in pathAndShareNames)
{
int shareNameKeyIndex = entry.Value.FindIndex(x => Regex.IsMatch(x.iniKeyName, @"path\d+_additional.+", RegexOptions.IgnoreCase));
str = PathManip.RemoveTrailingSlashInPath(entry.Key.iniValue);
splitStrings = str.Split(new string[] { "\\", "/", ":" }, StringSplitOptions.RemoveEmptyEntries);
// get the name of folder to be shared
if (splitStrings.Length > 0 && splitStrings[splitStrings.Length - 1].Length > 0)
{
if (!tempOneToManyDict.ContainsKey(entry.Key))
{
tempOneToManyDict[entry.Key] = new List<ConfigFileManager.Ini_KeyValue<string>>(pathAndShareNames[entry.Key]);
}
if (shareNameKeyIndex >= 0 && tempOneToManyDict[entry.Key][shareNameKeyIndex].iniValue.Length == 0)
{
tempOneToManyDict[entry.Key].RemoveAt(shareNameKeyIndex);
shareNameKeyIndex = -1;
}
if (shareNameKeyIndex < 0)
{
// get the folder name of the path and save it as default share name
iniVal.iniSectionName = "Auto-Generated";
iniVal.iniKeyName = "Auto-Generated-Share-Name";
iniVal.iniValue = splitStrings[splitStrings.Length - 1];
// add default share name to path
tempOneToManyDict[entry.Key].Add(iniVal);
}
else
{
iniVal = tempOneToManyDict[entry.Key][shareNameKeyIndex];
iniVal.iniValue += ", " + splitStrings[splitStrings.Length - 1];
tempOneToManyDict[entry.Key][shareNameKeyIndex] = iniVal;
}
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Key: " + entry.Key.iniKeyName
+ "\n" + indentation + "Value: " + entry.Key.iniValue
+ "\n" + indentation + "Error Description: The value above is invalid the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
}
pathAndShareNames = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>(tempOneToManyDict);
if (setupSuccessful)
pathAndShareNames = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>(tempOneToManyDict);
return setupSuccessful;
}
public bool createDirectories(string sectionName)
{
bool setupSuccessful = true;
DirectoryInfo di;
string msg, indentation;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n\n-=Creating Directories=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
dirsToCreate.Clear();
ConfigFileManager.parseConfigInfo(sectionName, dirsToCreate);
if (setupSuccessful)
{
if (dirsToCreate.Count == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. Nothing create";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
foreach (ConfigFileManager.Ini_KeyValue<string> dir in dirsToCreate)
{
di = new DirectoryInfo(Path.GetFullPath(dir.iniValue));
indentation = Common.getIndentation(1);
msg = "\n" + indentation + di.ToString();
// Create the directory only if it does not already exist.
if (di.Exists == false)
{
try
{
di.Create();
msg += " - SUCCESS";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS"); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
catch (Exception e)
{
msg += " - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
}
else
{
msg += " - SKIPPED. ( Directory already exists )";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SKIPPED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
if (!setupSuccessful)
break;
}
}
return setupSuccessful;
}
}
}

View File

@@ -0,0 +1,448 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class GutsConfigFileManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
// dictionary that stores key value pair for each entry in the GUTS config file
public List<ConfigFileManager.Ini_KeyValue<string>> gutsConfigEntries = new List<ConfigFileManager.Ini_KeyValue<string>>();
public ConfigFileManager.Ini_KeyValue<string> sm3seekerConfigFile = new ConfigFileManager.Ini_KeyValue<string>("");
public ConfigFileManager.Ini_KeyValue<string> gutsBinariesLocation = new ConfigFileManager.Ini_KeyValue<string>("");
Form m_parentForm;
public GutsConfigFileManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool processGutsConfigFile(string sectionName)
{
bool setupSuccessful = true;
string msg, errMsg = String.Empty, sourceFile, destFile = "";
string indentation = String.Empty;
bool performFileCopying = true;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Processing GUTS Config File=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
gutsConfigEntries.Clear();
ConfigFileManager.parseConfigInfo(sectionName, gutsConfigEntries);
readGutsInfo();
setupSuccessful = verifyConfigInfo();
if (setupSuccessful)
{
destFile = PathManip.RemoveTrailingSlashInPath(gutsBinariesLocation.iniValue) + "\\Sm3Seeker.cfg";
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(233, 31, 195);
textProp.wordIndex = 1;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Copying " + Path.GetFileName(sm3seekerConfigFile.iniValue);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
performFileCopying = true;
sourceFile = sm3seekerConfigFile.iniValue;
sourceFile = PathManip.GetProperFilePathCapitalization(sourceFile);
if (!File.Exists(sourceFile))
{
msg = " - FAILED. File " + sourceFile + " not found";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
if (File.Exists(destFile) && setupSuccessful)
{
msg = ((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.YESNO, null, "File " + destFile + " already exists.\n\n Would you like to overwrite it?", "Info", -1);
if (String.Equals(msg, "no", StringComparison.OrdinalIgnoreCase))
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.USER_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- SKIPPED by user.";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
performFileCopying = false;
}
}
if (setupSuccessful && performFileCopying)
{
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- From: " + sourceFile;
msg += "\n" + indentation + "- To: " + destFile;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "From:");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "To:");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = FileManip.CopyFile(Path.GetDirectoryName(sourceFile), sourceFile, Path.GetDirectoryName(destFile), destFile, true, FileAttributes.Normal, ref errMsg);
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- SUCCESS.";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set file to read-write access
if (FileManip.SetFileAttributeToReadAndWrite(destFile, ref errMsg))
{
if (gutsConfigEntries.Count > 0)
{
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(233, 31, 195);
textProp.wordIndex = 2;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Modifying file " + destFile;
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
string delimiter = "[,]";
// first we have to determine the correct keys based on the generic key provided in the INI file
// and add these dynamic keys to the existing dictionary of all the correct keys
foreach (ConfigFileManager.Ini_KeyValue<string> configEntry in gutsConfigEntries)
{
List<string> triplet = new List<string>(configEntry.iniValue.Split(new string[] { delimiter }, StringSplitOptions.RemoveEmptyEntries));
if (triplet.Count > 0)
triplet[0] = triplet[0].Trim();
if (triplet.Count > 1)
triplet[1] = triplet[1].Trim();
if (triplet.Count > 2)
triplet[2] = triplet[2].Trim();
// section, key and value exist
if (triplet.Count == 3 && triplet[0].Length > 0 && triplet[1].Length > 0 && triplet[2].Length > 0)
{
setupSuccessful = modifyGutsConfigFile(destFile, triplet[0], triplet[1], triplet[2]);
if (!setupSuccessful)
break;
}
}
}
}
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- FAILED. " + errMsg;
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
}
}
return setupSuccessful;
}
public bool modifyGutsConfigFile(string configFile, string configSectionName, string configKey, string configValue)
{
bool setupSuccessful = true;
string msg, errMsg = String.Empty;
string indentation = String.Empty;
Dictionary<string, string> gutsSourceFileToDestFile = new Dictionary<string, string>();
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
string pattern = @"(section +" + configSectionName + @"(?:(?!\nsection).)*\n" + configKey + @" +)[^;\r\n]+";
string replacement = "${1}" + configValue;
setupSuccessful = FileManip.ReplaceTextInFile(configFile, pattern, replacement, ref errMsg);
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "Setting " + configKey + "=" + configValue + " in section " + configSectionName;
if (setupSuccessful)
{
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
msg += " - FAILED.";
if (errMsg.Length > 0)
msg += " " + errMsg;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
return setupSuccessful;
}
public void readGutsInfo()
{
string[] keyDataPair;
Dictionary<string, string> keyAndValuePair = new Dictionary<string, string>();
string sectionName;
string[] sectionData;
sectionName = ConfigFileManager.enum_INI_SECTION_NAMES.GUTS_Info.ToString();
sectionData = ConfigFileManager.ms_configGeneralInfo.iniFile.ReadSectionData(sectionName);
gutsBinariesLocation.iniKeyName = "Guts_Bin_Dir";
gutsBinariesLocation.iniSectionName = sectionName;
sm3seekerConfigFile.iniKeyName = "sm3seeker_config_file";
sm3seekerConfigFile.iniSectionName = sectionName;
foreach (string path in sectionData)
{
keyDataPair = path.Split('=');
if (String.Equals(keyDataPair[0], gutsBinariesLocation.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
if (keyDataPair.Length == 2)
{
gutsBinariesLocation.iniValue = keyDataPair[1];
}
}
else if (String.Equals(keyDataPair[0], sm3seekerConfigFile.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
if (keyDataPair.Length == 2 && keyDataPair[1].Length > 0)
{
sm3seekerConfigFile.iniValue = Path.GetFullPath(keyDataPair[1]);
}
}
}
}
bool verifyConfigInfo()
{
bool setupSuccessful = true;
string indentation = String.Empty;
string msg, tempPath;
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
if (gutsBinariesLocation.iniValue.Length == 0)
{
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + gutsBinariesLocation.iniSectionName
+ "\n" + indentation + "Key: " + gutsBinariesLocation.iniKeyName
+ "\n" + indentation + "Value: " + gutsBinariesLocation.iniValue
+ "\n" + indentation + "Error Description: Either one or a combination of Section, Key, or Value is not defined in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
else if (sm3seekerConfigFile.iniValue.Length == 0)
{
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + sm3seekerConfigFile.iniSectionName
+ "\n" + indentation + "Key: " + sm3seekerConfigFile.iniKeyName
+ "\n" + indentation + "Value: " + sm3seekerConfigFile.iniValue
+ "\n" + indentation + "Error Description: Either one or a combination of Section, Key, or Value is not defined in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
if (setupSuccessful)
{
tempPath = Path.GetFullPath(gutsBinariesLocation.iniValue);
if (!Directory.Exists(gutsBinariesLocation.iniValue))
{
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + gutsBinariesLocation.iniSectionName
+ "\n" + indentation + "Key: " + gutsBinariesLocation.iniKeyName
+ "\n" + indentation + "Value: " + gutsBinariesLocation.iniValue
+ "\n" + indentation + "Error Description: The path defined in the value above is invalid. Translated path " + tempPath;
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
else
gutsBinariesLocation.iniValue = tempPath;
}
if (setupSuccessful)
{
tempPath = Path.GetFullPath(sm3seekerConfigFile.iniValue); ;
if (!File.Exists(sm3seekerConfigFile.iniValue))
{
indentation = Common.getIndentation(2);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + sm3seekerConfigFile.iniSectionName
+ "\n" + indentation + "Key: " + sm3seekerConfigFile.iniKeyName
+ "\n" + indentation + "Value: " + sm3seekerConfigFile.iniValue
+ "\n" + indentation + "Error Description: The path defined in the value above is invalid. Translated path " + tempPath;
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
else
sm3seekerConfigFile.iniValue = tempPath;
}
return setupSuccessful;
}
}
}

View File

@@ -0,0 +1,698 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class GutsSoftwareBuildAssistant
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
public event Action RestartApplication;
public List<ConfigFileManager.Ini_KeyValue<string>> gutsPrebuildParams = new List<ConfigFileManager.Ini_KeyValue<string>>();
Form m_parentForm;
public GutsSoftwareBuildAssistant(Form parentForm)
{
m_parentForm = parentForm;
}
// if one were to build GUTS from the files pulled from Synergy, the build will fail because
// additional files (source and headers) must be added to the GUTS project in order to build
// GUTS successfully. There's a perl script (dashboard.pl) that creates all the necessary files.
// But before the dashboard.pl can create all additional files, that path to the GUTS project
// must be specified in the windows environmental system variables and that the path to the Perl
// executable must be in the system Path variable. If these 2 things are not correct, the dashboard.pl
// will not be able to copy files to the GUTS project folder and GUTS will fail the build
// this function will ensure that everything is right to run the dashboard.pl and that it can create
// files and add them to the GUTS project folders.
public bool gutsPrebuildCheck(string sectionName)
{
string msg, indentation = String.Empty, gutsRootPath = "";
bool setupSuccessful = true;
ConfigFileManager.Ini_KeyValue<string> gutsDevelopmentFolder = new ConfigFileManager.Ini_KeyValue<string>("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 10;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=GUTS Pre-build Check=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
gutsPrebuildParams.Clear();
ConfigFileManager.parseConfigInfo(sectionName, gutsPrebuildParams);
if (setupSuccessful)
{
setupSuccessful = verifyGutsDirectoryStructure(ref gutsRootPath);
if (setupSuccessful)
setupSuccessful = runGutsPrebuildScript(gutsRootPath);
}
return setupSuccessful;
}
bool verifyGutsDirectoryStructure(ref string gutsRootPath)
{
bool setupSuccessful = true;
string msg, indentation = String.Empty;
Match regExMatch;
ConfigFileManager.Ini_KeyValue<string> gutsDevelopmentFolder = new ConfigFileManager.Ini_KeyValue<string>("");
List<string> paths = new List<string>();
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
gutsRootPath = "";
gutsDevelopmentFolder = getGutsDevelopmentFolderIniInfo();
if (gutsDevelopmentFolder.iniValue.Length == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + gutsDevelopmentFolder.iniSectionName
+ "\n" + indentation + "Key: " + gutsDevelopmentFolder.iniKeyName
+ "\n" + indentation + "Value: " + gutsDevelopmentFolder.iniValue
+ "\n" + indentation + "Error Description: The key or value is missing for the above section in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
if (setupSuccessful)
{
regExMatch = Regex.Match(gutsDevelopmentFolder.iniValue, @"(.+\\GUTS[^\\]*)\\?.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
gutsRootPath = regExMatch.Groups[1].Value;
}
else
gutsRootPath = PathManip.RemoveTrailingSlashInPath(gutsDevelopmentFolder.iniValue) + "\\" + "GUTS";
paths.Add(gutsRootPath);
paths.Add(gutsRootPath + "\\SM3_Tools\\Dashboard");
paths.Add(gutsRootPath + "\\SM3\\src\\app");
foreach (string path in paths)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Verify path \"" + PathManip.GetProperDirectoryCapitalization(path) + "\"";
if (Directory.Exists(path))
{
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
msg += " - FAILED.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
if (!setupSuccessful)
break;
}
}
return setupSuccessful;
}
bool runGutsPrebuildScript(string gutsRootPath)
{
bool environmentVarChanged = false;
string msg = "", additionalFileMissing = "", errMsg = "", indentation, dashboardScriptPath, currentPathEnvVar = "", currentSm3SeekerEnvVar = "";
bool setupSuccessful = true;
ConfigFileManager.Ini_KeyValue<string> genericIniInfo = new ConfigFileManager.Ini_KeyValue<string>("");
ConfigFileManager.Ini_KeyValue<string> pathAndNameOfAddtionalFilesList = new ConfigFileManager.Ini_KeyValue<string>("");
ConfigFileManager.Ini_KeyValue<string> perlBinaryPath = new ConfigFileManager.Ini_KeyValue<string>("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
pathAndNameOfAddtionalFilesList = getPathAndNameOfAddtionalFileList();
genericIniInfo = pathAndNameOfAddtionalFilesList;
perlBinaryPath = getPerlBinaryPathIniInfo();
if (genericIniInfo.iniValue.Length > 0)
genericIniInfo = perlBinaryPath;
if (genericIniInfo.iniValue.Length == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + genericIniInfo.iniSectionName
+ "\n" + indentation + "Key: " + genericIniInfo.iniKeyName
+ "\n" + indentation + "Value: " + genericIniInfo.iniValue
+ "\n" + indentation + "Error Description: The key or value is missing for the above section in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
if (setupSuccessful)
{
if (File.Exists(pathAndNameOfAddtionalFilesList.iniValue))
{
verifyAdditionalFilesAlreadyExistInGutsProject(gutsRootPath, pathAndNameOfAddtionalFilesList.iniValue, ref additionalFileMissing, ref errMsg);
if (errMsg.Length > 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Parsing file \"" + pathAndNameOfAddtionalFilesList.iniValue + "\" - FAILED. " + errMsg;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
else if (additionalFileMissing.Length > 0)
{
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.INFO, null, "File \"" + additionalFileMissing + "\" is missing. \n\nProceeding with running pre-build script to create necessary files." , "Info", -1);
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Verify additional files already exist within \"" + gutsRootPath + "\" - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Verify file \"" + pathAndNameOfAddtionalFilesList.iniValue + "\" - FAILED.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
if ( msg.Length > 0 )
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
// at least 1 required file is missing from the GUTS project folder, we must run script to copy all the necessary files to GUTS folder
if (setupSuccessful && additionalFileMissing.Length > 0)
{
dashboardScriptPath = gutsRootPath + @"\SM3_Tools\Dashboard\dashboard.pl";
if (!File.Exists(dashboardScriptPath))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Verify file \"" + dashboardScriptPath + "\" - FAILED. File does not exist";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
string perlAppPath = PathManip.AddTrailingSlashToPath(perlBinaryPath.iniValue) + "Perl.exe";
if (!File.Exists(perlAppPath))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Verify file \"" + perlAppPath + "\" - FAILED. File does not exist. Please install Perl.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
if (setupSuccessful)
{
try
{
currentPathEnvVar = System.Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
perlBinaryPath.iniValue = PathManip.RemoveTrailingSlashInPath(perlBinaryPath.iniValue);
}
catch (Exception e)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Querying system environment variable \"Path\" - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
}
if (setupSuccessful)
{
try
{
currentSm3SeekerEnvVar = System.Environment.GetEnvironmentVariable("SM3_SEEKER", EnvironmentVariableTarget.Machine);
}
catch (Exception e)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Querying system environment variable \"SM3_SEEKER\" - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
}
if (setupSuccessful)
{
// if the perl binary path is not specified in the system environment variable "Path", we add it
if (!Regex.IsMatch(currentPathEnvVar, @".*" + Regex.Escape(perlBinaryPath.iniValue) + @".*", RegexOptions.IgnoreCase))
{
currentPathEnvVar += ";" + perlBinaryPath.iniValue;
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Setting environment variable [Path=$Path;" + perlBinaryPath.iniValue + "]";
try
{
System.Environment.SetEnvironmentVariable("Path", currentPathEnvVar, EnvironmentVariableTarget.Machine);
environmentVarChanged = true;
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
catch (Exception e)
{
msg += " - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
if (setupSuccessful)
{
// if the SM3_SEEKR path does not match the GUTS Development Folder path, we change it
if (!Regex.IsMatch(currentSm3SeekerEnvVar, @"^" + Regex.Escape(gutsRootPath) + @"\\SM3$", RegexOptions.IgnoreCase))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Setting environment variable [SM3_SEEKER=" + gutsRootPath + @"\SM3]";
try
{
System.Environment.SetEnvironmentVariable("SM3_SEEKER", gutsRootPath + @"\SM3", EnvironmentVariableTarget.Machine);
environmentVarChanged = true;
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
catch (Exception e)
{
msg += " - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
if (environmentVarChanged)
{
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.INFO, null, "The application has made changes/additions to the System Environment Variables.\n\n The application must be restarted for the System Environment Variables to take effect.\n\n Click OK to close the application and run the application again.", "Info", -1);
// raise the event to restart the application
RestartApplication();
}
if (setupSuccessful && !((frmSetupStatusDisplay)m_parentForm).applicationNeedsToBeRestarted())
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Regular);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Executing script to create required files to GUTS project folder";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
msg = ((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.YESNO, null, "Would you like to run the perl script to copy necessary files to GUTS folder?", "Info", -1);
if (String.Equals(msg, "yes", StringComparison.OrdinalIgnoreCase))
{
try
{
var process = Process.Start(perlAppPath, dashboardScriptPath);
process.WaitForExit();
verifyAdditionalFilesAlreadyExistInGutsProject(gutsRootPath, pathAndNameOfAddtionalFilesList.iniValue, ref additionalFileMissing, ref errMsg);
if (errMsg.Length == 0 && additionalFileMissing.Length == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
if (errMsg.Length > 0 )
msg = " - FAILED. " + errMsg;
else
msg = " - FAILED. " + additionalFileMissing + " not found.";
setupSuccessful = false;
}
}
catch (Exception e)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = " - FAILED. Error executing file " + dashboardScriptPath + ". " + e.Message;
setupSuccessful = false;
}
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = " - FAILED. User chooses to not run script.";
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
return setupSuccessful;
}
void verifyAdditionalFilesAlreadyExistInGutsProject(string gutsRootPath, string pathAndNameToListOfFiles, ref string fileMissing, ref string errMsg)
{
string line, filePart2, filePath;
Match regExMatch;
errMsg = "";
fileMissing = "";
FileStream fs = null;
StreamReader reader = null;
try
{
fs = new FileStream(pathAndNameToListOfFiles, FileMode.Open, FileAccess.Read);
reader = new StreamReader(fs, Encoding.Default);
while ((line = reader.ReadLine()) != null)
{
line = line.Trim();
if (line.Length > 0)
{
regExMatch = Regex.Match(line, @"(.*\\)?(SM3\\.+)", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
filePart2 = regExMatch.Groups[2].Value;
filePath = gutsRootPath + "\\" + filePart2;
if (!File.Exists(filePath))
{
fileMissing = filePath;
break;
}
}
}
}
}
catch (Exception ex)
{
errMsg = ex.Message;
}
finally
{
if (reader != null)
{
reader.Close();
fs.Close();
}
}
}
ConfigFileManager.Ini_KeyValue<string> getPerlBinaryPathIniInfo()
{
ConfigFileManager.Ini_KeyValue<string> iniInfo = new ConfigFileManager.Ini_KeyValue<string>("");
iniInfo.iniKeyName = "perl_binary_path";
iniInfo.iniSectionName = ConfigFileManager.enum_INI_SECTION_NAMES.GUTS_Pre_Build_Assistance.ToString();
foreach (ConfigFileManager.Ini_KeyValue<string> iniParam in gutsPrebuildParams)
{
if (String.Equals(iniParam.iniKeyName, iniInfo.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
iniInfo = iniParam;
if (iniInfo.iniValue.Length > 0)
iniInfo.iniValue = Path.GetFullPath(iniInfo.iniValue);
break;
}
}
return iniInfo;
}
ConfigFileManager.Ini_KeyValue<string> getGutsDevelopmentFolderIniInfo()
{
ConfigFileManager.Ini_KeyValue<string> iniInfo = new ConfigFileManager.Ini_KeyValue<string>("");
iniInfo.iniKeyName = "GUTS_Development_Folder";
iniInfo.iniSectionName = ConfigFileManager.enum_INI_SECTION_NAMES.GUTS_Pre_Build_Assistance.ToString();
foreach (ConfigFileManager.Ini_KeyValue<string> iniParam in gutsPrebuildParams)
{
if (String.Equals(iniParam.iniKeyName, iniInfo.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
iniInfo = iniParam;
if (iniInfo.iniValue.Length > 0)
iniInfo.iniValue = Path.GetFullPath(iniInfo.iniValue);
break;
}
}
return iniInfo;
}
ConfigFileManager.Ini_KeyValue<string> getPathAndNameOfAddtionalFileList()
{
ConfigFileManager.Ini_KeyValue<string> iniInfo = new ConfigFileManager.Ini_KeyValue<string>("");
iniInfo.iniKeyName = "list_of_additional_files";
iniInfo.iniSectionName = ConfigFileManager.enum_INI_SECTION_NAMES.GUTS_Pre_Build_Assistance.ToString();
foreach (ConfigFileManager.Ini_KeyValue<string> iniParam in gutsPrebuildParams)
{
if (String.Equals(iniParam.iniKeyName, iniInfo.iniKeyName, StringComparison.OrdinalIgnoreCase))
{
iniInfo = iniParam;
if (iniInfo.iniValue.Length > 0)
iniInfo.iniValue = Path.GetFullPath(iniInfo.iniValue);
break;
}
}
return iniInfo;
}
}
}

View File

@@ -0,0 +1,663 @@
; ************************************************* AUTO SETUP CONFIGURATION FILE *****************************************************
; Description:
; This is an INI file which contains the configuration information for the automated setup of either an
; ENGINEERING or PRODUCTION environment in a Windows OS.
;
; Author: Duc Le
;
; ******************************************************************************************************************************
;
;
;
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
[General]
Program_Name = SM3
; 64-bit or 32-bit. Possible values: 32 or 64
Application_Platform = 32
[Global_Settings]
Always_Run_Application_Using_Admin_Account = true
Suppress_All_Prompts = true
Provide_Windows_Password_For_Auto_Login = true
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
; This section defines all the setup steps to be performed and allow the user the option of enabling/disabling each step
; The key can be anything.
; The value must define the setup step and its associated section name separated by comma: Setup_Step,Section_Name
; Below is a list of all possible setup steps:
; CONFIGURE_NETWORK_ADAPTERS
; RUN_APPLICATIONS
; INSTALL_SOFTWARE_PACKAGES
; ENABLE_INTERNET_INFORMATION_SERVICES
; CREATE_DIRECTORIES
; CREATE_NETWORK_SHARES
; SET_ENVIRONMENT_VARIABLES
; SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS
; TRANSFER_FILE_PACKAGES
; MODIFY_WINDOWS_REGISTRY
; PROCESS_GUTS_CONFIG_FILE
; CREATE_WINDOWS_SHORTCUTS
; ASSIST_BUILDING_GUTS_APP
; REMOVE_FILES_FOLDERS
;
; The setup setup can be run more than once by creating another key and assigned the setup step to it
; Each setup step needs a section name. Section name provides all the information necessary for the setup step
; The sequence of the execution of the setup steps will be in the same order as they are specified.
; ******************************************************************************************************************************
[Setup_Step_Manager]
step = RUN_APPLICATIONS,Extract_Visual_Studio_Archives
step = TRANSFER_FILE_PACKAGES,DVD_Software_Suite
step = RUN_APPLICATIONS,Extract_Software_Suite
step = INSTALL_SOFTWARE_PACKAGES,Install_Microsoft_HotFix
step = RUN_APPLICATIONS,Import_Trusted_Publisher_Certificates
step = INSTALL_SOFTWARE_PACKAGES,Install_Software
step = RUN_APPLICATIONS,Shut_Down_National_Instrument_Processes
step = REMOVE_FILES_FOLDERS , Files_Folders_Removal
;step = ENABLE_INTERNET_INFORMATION_SERVICES,Windows_Features
;step = CREATE_DIRECTORIES,Paths_Creation
;step = CREATE_NETWORK_SHARES,Paths_Sharing
;step = SET_ENVIRONMENT_VARIABLES,Env_Variables
;step = SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS
;step = TRANSFER_FILE_PACKAGES,Files_Transfer_Packages
;step = MODIFY_WINDOWS_REGISTRY,Windows_Registry
;step = PROCESS_GUTS_CONFIG_FILE,GUTS_Config_File
;step = CREATE_WINDOWS_SHORTCUTS,Windows_Shortcuts
;step = ASSIST_BUILDING_GUTS_APP,GUTS_Pre_Build_Assistance
;step = REMOVE_FILES_FOLDERS , Files_Folders_Removal
[Install_Microsoft_HotFix]
app1_name = HotFix for Windows (KB2921916)
app1_setup_file = c:\windows\system32\wusa.exe
app1_setup_argument = "{user_temp_folder}\mk698\extraction\MS_HotFix\Windows6.1-KB2921916-x64.msu" /quiet /norestart
app1_reg_path = SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\Packages\Package_2_for_KB2921916~31bf3856ad364e35~amd64~~6.1.1.0
app1_reg_type = local_machine
app1_reboot_computer_at_completion = yes
app1_reboot_computer_immediately = yes
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to install various software application
; For each software application to be installed, 4 things can be defined:
;
; Possible keys:
; app#_name (REQUIRED. Name of the application to be installed/checked)
; app#_setup_file (OPTIONAL. Path and name of the installer)
; - the setup file can make use of macros. Look below for the available macros
; app#_setup_argument (OPTIONAL. Argument for the setup file. Usually to perform unattended install)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; app#_setup_confirm_prompt (OPTIONAL. Prompt user to confirm before installation starts.)
; - possible values: yes, no
; - yes: there will be prompt asking user confirm/refuse install
; - no: installation will start automatically ( this is the default )
; app#_exe_file (REQUIRED only if app#_hklm_reg_key is not specified.
; This is used to verify that the software successfully installed)
; app#_reg_path (REQUIRED only if app#_exe_file is not specified. Registry folder path, not including valuename)
; app#_reg_type (REQUIRED only if app#_reg_key is specified)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; app#_reg_value (REQUIRED only if app#_reg_key is specified. Registry value name's value)
; app#_reg_name (REQUIRED only if app#_reg_key is specified. Registry value name)
; app#_reg_compare (REQUIRED only if app#_reg_key is specified. Compare operator between value name's value specified here versus actual value read from registry)
; - there are only six options for this key ( eq, lt, gt, lte, gte, ne )
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; example 1:
; app1_name = Perl 5.6.1.638
; app1_setup_file = {user_temp_folder}\Installer.bat
; app1_exe_file = C:\Perl\bin\perl.exe
;
; example 2:
; app1_reg_path = SOFTWARE\National Instruments\NI-488.2\CurrentVersion
; app1_reg_type = local_machine
; app1_reg_value = 15.0
; app1_reg_name = Version
; app1_reg_compare = gte
; app1_name = National Instrument 488.2 (v15 or higher)
; app1_setup_file = C:\ni\setup.exe
;
; example 3:
; app1_exe_file = C:\Perl\bin\perl.exe
; app1_name = Perl 5.6.1.638
;
; example 4:
; app1_name = Sapera LT 8.11 (x64)
; app1_setup_file = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\Software\TeledyneDalsa\Sapera_LT_8.11_RuntimeSetup.exe
; app1_setup_argument = -s -f1"{app1_setup_file}\sapera_setup.iss"
; app1_reg_path = SOFTWARE\Teledyne DALSA\Sapera LT
; app1_reg_type = local_machine
; app1_reg_name = IsSaperaFrameGrabberSupport
;
; ******************************************************************************************************************************
; Visual Studio ClassRoot Registry Keys
;
; {"VS2005", "VisualStudio.DTE.8.0"},
; {"VS2008", "VisualStudio.DTE.9.0"},
; {"VS2010", "VisualStudio.DTE.10.0"},
; {"VS2012", "VisualStudio.DTE.11.0"},
; {"VS2013", "VisualStudio.DTE.12.0"},
; {"VS2015", "VisualStudio.DTE.13.0"}
;
; Visual Studio Redistributable Local_Machine Registry Keys
;
; {"VS2005_x64", @"SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182"},
; {"VS2005_x86", @"SOFTWARE\Classes\Installer\Products\c1c4f01781cc94c4c8fb1542c0981a2a"},
; {"VS2008_x64", @"SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D"},
; {"VS2008_x86", @"SOFTWARE\Classes\Installer\Products\6E815EB96CCE9A53884E7857C57002F0"},
; {"VS2010_x64", @"SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F"},
; {"VS2010_x86", @"SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A"},
; {"VS2012_x64", @"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}"},
; {"VS2012_x86", @"SOFTWARE\Classes\Installer\Dependencies\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}"},
; {"VS2013_x64", @"SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f}"},
; {"VS2013_x86", @"SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}"},
; {"VS2015_x64", @"SOFTWARE\Classes\Installer\Dependencies\{3ee5e5bb-b7cc-4556-8861-a00a82977d6c}"},
; {"VS2015_x86", @"SOFTWARE\Classes\Installer\Dependencies\{23daf363-3020-4059-b3ae-dc4ad39fed19}"}
;
; ******************************************************************************************************************************
[Install_Software]
app1_name = Visual Studio 2012
app1_setup_argument = /passive /norestart
app1_reg_path = VisualStudio.DTE.11.0
app1_reg_type = classes_root
app1_setup_file = {user_temp_folder}\mk698\extraction\vs2012\vs_professional.exe
app2_name = Visual Studio 2012 - Update 4
app2_setup_file = {user_temp_folder}\mk698\extraction\vs2012_update4\VS2012.4.exe
app2_setup_argument = /passive /norestart
app2_reg_path = SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\11.0\CompilerCore\1033
app2_reg_type = local_machine
app2_reg_value = 11.0.61030
app2_reg_name = UpdateVersion
app2_reg_compare = eq
app3_name = SSI Test Executive 6.42.1 (v1.0.0)
app3_setup_file = c:\windows\system32\msiexec.exe
app3_setup_argument = /i "{user_temp_folder}\mk698\extraction\SSI_Test_Exec_v6_42_1\win32\SSI Test Executive 6.42.1.msi" /passive /norestart ALLUSERS{equal_sign}1
app3_reg_display_name = SSI Test Executive 6.42.1
app3_reg_type = local_machine
app3_reg_value = 1.0.0
app3_reg_name = DisplayVersion
app3_reg_compare = eq
app4_name = ActivePerl 5.8.8 Build 817
app4_setup_file = c:\windows\system32\msiexec.exe
app4_setup_argument = /i "{user_temp_folder}\mk698\extraction\ActivePerl_v5_8_8\ActivePerl-5.8.8.817-MSWin32-x86-257965.msi" /passive /norestart
app4_reg_display_name = ActivePerl 5.8.8 Build 817
app4_reg_type = local_machine
app4_reg_value = 5.8.817
app4_reg_name = DisplayVersion
app4_reg_compare = eq
app5_name = Windows Software Development Kit for Windows 8.1
app5_setup_file = {user_temp_folder}\mk698\extraction\WinSDK_v8_1\sdksetup.exe
app5_setup_argument = /quiet /norestart
app5_reg_display_name = Windows Software Development Kit
app5_reg_type = local_machine
app5_reg_value = 8.100.26936
app5_reg_name = DisplayVersion
app5_reg_compare = eq
app5_reboot_computer_at_completion = yes
; needed for National Instrument Drivers
app6_name = Microsoft .NET Framework 4.6.2
app6_setup_file = {user_temp_folder}\mk698\extraction\DotNet_Framework_4_6_2\NDP462-KB3151800-x86-x64-AllOS-ENU.exe
app6_setup_argument = /passive /norestart
app6_reg_display_name = Microsoft .NET Framework 4.6.2
app6_reg_type = local_machine
app6_reg_value = 4.6
app6_reg_name = DisplayVersion
app6_reg_compare = gte
; app61_name = NI LabWindows/CVI Runtime (v. 17)
; app61_setup_file = {user_temp_folder}\mk698\extraction\NI_LabWindows_CVI_Runtime_v17\setup.exe
; app61_setup_argument = /qb /r:n /AcceptLicenses yes
; app61_reg_display_name = NI LabWindows/CVI SxS Runtime 2017
; app61_reg_type = local_machine
; app61_reg_value = 17
; app61_reg_name = DisplayVersion
; app61_reg_compare = gte
; app61_setup_reboot_computer = yes
app62_name = NI LabWindows/CVI (v. 17)
app62_setup_file = {user_temp_folder}\mk698\extraction\NI_LabWindows_CVI_v17\Distributions\CVI\setup.exe
app62_setup_argument = "{app62_setup_file}\specfile.txt" /qb /r:n /AcceptLicenses yes
app62_reg_display_name = NI LabWindows/CVI 2017
app62_reg_type = local_machine
app62_reg_value = 17
app62_reg_name = DisplayVersion
app62_reg_compare = gte
app62_reboot_computer_at_completion = yes
app7_name = NI 488.2 (v. 17)
app7_setup_file = {user_temp_folder}\mk698\extraction\NI_4882_v17\setup.exe
app7_setup_argument = /qb /r:n /AcceptLicenses yes
app7_reg_display_name = NI-488.2 17.0
app7_reg_type = local_machine
app7_reg_value = 17
app7_reg_name = DisplayVersion
app7_reg_compare = gte
app7_reboot_computer_at_completion = yes
app8_name = NI VXI (v. 16)
app8_setup_file = {user_temp_folder}\mk698\extraction\NI_VXI_v17\setup.exe
app8_setup_argument = /qb /r:n /AcceptLicenses yes
app8_reg_display_name = NI-VXI 16.0
app8_reg_type = local_machine
app8_reg_value = 16
app8_reg_name = DisplayVersion
app8_reg_compare = gte
app8_reboot_computer_at_completion = yes
app9_name = NI IVI Compliance Package (v. 17)
app9_setup_file = {user_temp_folder}\mk698\extraction\NI_IVI_Compliance_Package_v17\setup.exe
app9_setup_argument = /qb /r:n /AcceptLicenses yes
app9_reg_display_name = NI IVI Compliance Package 17.0
app9_reg_type = local_machine
app9_reg_value = 17
app9_reg_name = DisplayVersion
app9_reg_compare = gte
app9_reboot_computer_at_completion = yes
app10_name = NI Serial (v. 17)
app10_setup_file = {user_temp_folder}\mk698\extraction\NI_Serial_v17\setup.exe
app10_setup_argument = /qb /r:n /AcceptLicenses yes
app10_reg_display_name = NI-Serial Runtime 17.0
app10_reg_type = local_machine
app10_reg_value = 17
app10_reg_name = DisplayVersion
app10_reg_compare = gte
app11_name = NI Switch (v. 17)
app11_setup_file = {user_temp_folder}\mk698\extraction\NI_Switch_v17\setup.exe
app11_setup_argument = /qb /r:n /AcceptLicenses yes
app11_reg_display_name = NI-SWITCH 17.0
app11_reg_type = local_machine
app11_reg_value = 17
app11_reg_name = DisplayVersion
app11_reg_compare = gte
app11_reboot_computer_at_completion = yes
app12_name = Sealevel SeaMAX (v3.04)
app12_setup_file = {user_temp_folder}\mk698\extraction\SeaMAX_v3_04\sx03040001.exe
app12_setup_argument = -s -f1{user_temp_folder}\mk698\extraction\SeaMAX_v3_04\seamax_install_params.iss
app12_reg_display_name = SeaMAX
app12_reg_type = local_machine
app12_reg_value = 3.4.0.1
app12_reg_name = DisplayVersion
app12_reg_compare = gte
;app2_name = Sealevel SeaMACV5 (v5.0.23)
;app2_setup_file = {user_temp_folder}\mk698\extraction\SeaMACV5_v5_0_23\SM050023.exe
; app2_setup_argument = -s -f1{user_temp_folder}\mk698\extraction\SeaMACV5_v5_0_23\seamac_install_params.iss
; app2_reg_display_name = SeaMAC V5
; app2_reg_type = local_machine
; app2_reg_value = 5.0.23
; app2_reg_name = DisplayVersion
; app2_reg_compare = eq
; app13_name = Sealevel SeaMAC (v5.0.24)
; app13_setup_file = {user_temp_folder}\mk698\extraction\SeaMAC_v5_0_24\SM050024RC4.exe
; app13_setup_argument = /S /v/qn
; app13_reg_display_name = SeaMAC
; app13_reg_type = local_machine
; app13_reg_value = 5.0.24
; app13_reg_name = DisplayVersion
; app13_reg_compare = eq
app13_name = Sealevel SeaMAC (v6)
app13_setup_file = {user_temp_folder}\mk698\extraction\SeaMAC_v6\SM060000.exe
app13_setup_argument = /S /v/qn
app13_reg_display_name = SeaMAC
app13_reg_type = local_machine
app13_reg_value = 6.0
app13_reg_name = DisplayVersion
app13_reg_compare = eq
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to run various applications or scripts
;
; Possible keys:
; app#_description (OPTIONAL. Describe the purpose of running this application)
; app#_path (REQUIRED. Full path and name of the application to be run)
; - the path can take advantage of using macros. Look below for the available macros
; app#_is_console (REQUIRED. Specify if the application is a console application (i.e. DOS application)
; - value is either true/false
; app#_argument (OPTIONAL. Arguments to be passed to the application)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; - sometimes, the argument maybe include equal sign in them, but we can't have equal sign
; in the value of the INI. To make it possible, if an equal sign is needed in the ini file
; use <eq> in place of =
;
; app#_argument_path# - for each of these keys, there must be a corresponding {app#_argument_path#} defined in the value of app#_argument
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; Example 1:
; app1_path = C:\ReleaseIB_Production\app.exe
; app1_arguments = -role Datasrv -suite LSPS3 -production
;
; Example 2:
; app1_description = Extracting ActivePerl archive
; app1_path = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
;
; Example 3:
; app1_description = Extracting ActivePerl archive
; app1_path = {cd_drive}\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
; ******************************************************************************************************************************
[Extract_Software_Suite]
app1_description = Extracting MK698 software suite
app1_path = {user_temp_folder}\mk698\7-Zip\7z.exe
app1_is_console = true
app1_argument = x "{user_temp_folder}\mk698\MK698Software.7z.001" -o"{user_temp_folder}\mk698\extraction" -aos -y
[Extract_Visual_Studio_Archives]
app1_description = Extracting Visual Studio 2012 Archive
app1_cd_label = Visual Studio 2012
app1_path = {cd_drive}\7-Zip\7z.exe
app1_is_console = true
app1_argument = x "{cd_drive}\msvs2012.7z" -o"{user_temp_folder}\mk698\extraction\vs2012" -aos -y
app2_description = Extracting Visual Studio 2012 Update 4 Archive
app2_cd_label = Visual Studio 2012
app2_path = {cd_drive}\7-Zip\7z.exe
app2_is_console = true
app2_argument = x "{cd_drive}\msvs2012_update4.7z" -o"{user_temp_folder}\mk698\extraction\vs2012_update4" -aos -y
[Import_Trusted_Publisher_Certificates]
app1_description = Importing trusted publisher certificate for SeaLevel SeaMAX Driver
app1_path = c:\windows\system32\certutil.exe
app1_is_console = true
app1_argument = -addstore "TrustedPublisher" "{user_temp_folder}\mk698\extraction\SeaMax_v3_04\pubcert.cer"
app2_description = Importing trusted publisher certificate for SeaLevel SeaMAC Driver
app2_path = c:\windows\system32\certutil.exe
app2_is_console = true
app2_argument = -addstore "TrustedPublisher" "{user_temp_folder}\mk698\extraction\SeaMAC_v6\pubcert.cer"
[Shut_Down_National_Instrument_Processes]
app1_description = Killing process nierserver.exe
app1_path = c:\windows\system32\taskkill.exe
app1_is_console = true
app1_argument = /f /im nierserver.exe
;
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Modify Network Adapter's settings
;
; Possible keys:
; nic#_pci_location ( REQUIRED.)
; - the value must be in the form of: #,#,# ( bus, device, function)
; i.e.: 0,25,0 - bus = 0, device = 25, function = 0
; nic#_adapter_name (OPTIONAL. Set the name of the network adapter)
; nic#_ip_and_subnet (OPTIONAL. Set ip address and subnet mask of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,255.255.255.0
; nic#_default_gateway# (OPTIONAL. Default gateway of the network adapter)
; - the value must be in the form of: #.#.#.#
; i.e.: 192.168.0.1
; nic#_dns_servers (OPTIONAL. Set DNS servers of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,192.168.0.11
; nic#_link_speed (OPTIONAL. Set the link speed of the network adapter)
; - Before using this option. Make sure that the network adapter supports link speed setting
; This is really a registry change for the network adapter. The registry name is *SpeedDuplex
; The value for *SpeedDuplex is usually a digit ranging from 0-5.
; Here's an example:
; 0 - Auto Negotiate
; 1 - 10Mbps Half Duplex
; 2 - 10Mbps Full Duplex
; 3 - 100Mpbs Half Duplex
; 4 - 100Mbps Full Duplex
; 6 - 1Gpbs Full Duplex
; There's no 5 defined because there's no 1Gpbs Half Duplex
; IMPORTANT: The above example was taken from a Intel network card. These numbers could
; mean something else different from one network card to the next. Refer to the network
; adapter's manufacturer manual for the actual numbers and their meanings.
;
; nic#_enable_dhcp (OPTIONAL. Set network adapter to use DHCP)
; - the value must be either: true/false
; - if this is set to true, all the other settings above, except link speed, will be ignored
; this will effectively set IP and DNS Servers to be obtained automatically
;
; Example 1:
; nic1_pci_location = 0,25, 0
; nic1_link_speed = 2
; nic1_adapter_name = My Connection
; nic1_enable_dhcp = false
; nic1_ip_and_subnet = 192.168.0.10 , 255.255.255.0
; nic1_default_gateway = 192.168.0.1
; nic1_dns_servers = 192.168.0.5, 192.168.0.6
;
; ******************************************************************************************************************************
[Network_Interface_Cards]
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to remove/delete various files or folders
;
; Possible keys:
; item (REQUIRED. This is either a file or folder to be removed)
;
; If the item is a folder, user has the option to specify whether or not to delete the folder recursively. To specify to delete
; a folder recursively, add the word "recursive" right after the path separated by a comma
;
; The path can also include user desktop path or temporary folder
; for desktop path, use macro: {user_desktop}
; for temporary folder, use macro: {user_temp_folder}
;
; Example 1 - Delete a file:
; item = A:\test\test.hpp
;
; Example 2 - Delete a folder recursively:
; item = A:\test\test2,recursive
;
; Example 3 - Delete only the files contained in the folder:
; item = A:\test\test2
;
; Example 4 - Delete a folder on the user's desktop:
; item = {user_desktop}\test2
;
; Example 5 - Delete a folder in the user's temporary folder
; item = {user_temp_folder}\test2
; ******************************************************************************************************************************
[Files_Folders_Removal]
item = {user_temp_folder}\mk698,recursive
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to copy various packages of files from a source location to destination location
; Each XML file contains at least 1 package of files. Each file has a source and destination locations
; Key name can be anything
; Value must a be a path to a XML file
;
; example 1:
; file_package = package1.xml
; ******************************************************************************************************************************
[DVD_Software_Suite]
file_package = .\PackagesFromCD.xml
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Specify all the paths to be created
; Possible keys:
; path (REQUIRED. Valid path to be created)
;
; example:
; path1 = C:\DataIIB\data\Block_IB\CV
; path2 = C:\DataIIB\data\Block_IB\General\Logs
; ******************************************************************************************************************************
[Paths_Creation]
path = C:\ReleaseIB_Engineering\
path = C:\ReleaseIB_Production\
path = C:\DataIB\data\Block_IB\CV
path = C:\DataIB\data\Block_IB\General\Logs
path = C:\DataIB\data\Block_IB\General\Scripts
path = C:\DataIB\data\Block_IB\General\Temp\SingleStepScript
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; To share a folder, must provide path to a folder.
; Share names are optional as the folder name will be used as the default share name.
; Any share name defined here will be used as additional share name for its corresponding folder
; The # in "path#" must match in both keys. A folder can have more than one share name.
; Possible keys:
; path# (OPTIONAL. A valid path to be shared)
; path#_additional_share_names (OPTIONAL. Additional share names associated with a path)
; - Define one or more shares names separated by comma
; path#_allowed_accounts ( Windows Built-In, local or domain accounts to be added to the permission list for this share with Full Control )
; - if this is not defined, this network share will be accessible to everyone with Full Control
; - if defined, the value must be in the following format:
; User1,User2,User3 (if more than one account is defined, separate by comma)
; The account name must either be a built-in window account or local/domain account
; if the account name is a built-in window account, it can only be one of the following:
; - everyone, authenticated users
; if the account name is a local/domain account it must be in this format: DOMAIN\UserAccountName
;
; example:
; path1 = C:\DataIIB\
; path1_additional_share_names = DataIIB1, DataIIB2
; path1_allowed_accounts = Authenticated Users,US\1117637
; path2 = C:\DataIA
; path2__additional_share_names = DataIA_1
; path2_allowed_accounts = MYCOMPUTERNAME\Duc
; path3 = C:\DataIC
; ******************************************************************************************************************************
[Paths_Sharing]
path1 = C:\ReleaseIB_Engineering\
path2_additional_share_names = Data
path2 = C:\DataIB\
path3_additional_share_names = Release
path3 = C:\ReleaseIB_Production\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create windows system environment variables
; the key would be the system environment variable name.
;
; Note:
; Any key defined here will have its valued replaced, except for "path" because path is a window's system environment variable
; If a key's name is path, the value specified will be appendeding to existing value
;
; path can have one or more values separated by commas
; Example:
; path = C:\folder1
; path = C:\folder1, C:\folder2
; ******************************************************************************************************************************
[Env_Variables]
SM3_SEEKER = C:\Development\GUTS\SM3
; the address of the computer where all the data of each test is saved before being pushed to the network
SM3_SKR_SERVER = localhost
; the address of the computer where all test data are pushed to after testing
SM3_SKR_NETWORK = localhost
path = C:\Perl\bin\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Add/Modify or Delete registry's key
;
; Possible keys:
; reg#_action ( REQUIRED. What action to perform)
; - there are only 2 actions ( add/modify, delete)
; reg#_path (REQUIRED. Registry folder path, not including valuename)
; reg#_type (REQUIRED)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; reg#_name_value_pair# (Optional. Registry name values and their names)
; - the registry key defined by registry path can have multiple value names and their associated values
; - Format of the value: [name:***,value:***,type:***] - replace *** with actual text
; - name can be anything
; - value is either numeric or alphanumeric depending on type
; - type can only be 1 of 4: string, multi_string, dword, qword
; If type is dword or qword then value can only be numeric
; If type is multi-string, then format of the value must be:
; [name:***,:value:***:value:***...,type:multi_string]
;
; Example 1:
; reg1_action = add/modify
; reg1_path = SOFTWARE\MySoftware\
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version,value:3,type:string]
; reg1_name_value_pair2 = [name:Version2,:value:3:value:34,type:multi-string]
;
; Example 2:
; reg1_action = add/modify
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
;
; Example3:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version]
;
; Example4:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; ******************************************************************************************************************************
[Windows_Registry]
;reg1_action = delete
;reg1_path = SOFTWARE\Duc\
;reg1_type = local_machine
;reg1_name_value_pairs = Versionn[:]3[,]ginrl[:]boy
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create shortcuts on the user's desktop
;
; example:
; shortcut1_name = Data Server
; shortcut1_target_path = C:\ReleaseIB_Production\app.exe
; shortcut1_arguments = -role datasrv -suite lsps3 -production
; ******************************************************************************************************************************
[Windows_Shortcuts]
shortcut1_name = Data Server
shortcut1_target_path = C:\ReleaseIB_Production\app.exe
shortcut1_arguments = -role datasrv -suite lsps3 -production -no_hw
shortcut2_name = Guts Server
shortcut2_target_path = C:\ReleaseIB_Production\app.exe
shortcut2_arguments = -role gutssrv -suite lsps3 -production -no_hw
shortcut3_name = Guts Auto
shortcut3_target_path = C:\ReleaseIB_Production\app.exe
shortcut3_arguments = -role auto1b -suite lsps3 -production -no_hw
shortcut4_name = Guts Manual
shortcut4_target_path = C:\ReleaseIB_Production\app.exe
shortcut4_arguments = -role gutsman -suite lsps3 -production -no_hw

View File

@@ -0,0 +1,452 @@
; ************************************************* SM3 CONFIGURATION FILE *****************************************************
; Description:
; This is an INI file which contains the configuration information for the automated setup of either an
; ENGINEERING or PRODUCTION environment for developing or running SM3 GUTS (Guidance Unit Test Software)
;
; Author: Duc Le
;
; ******************************************************************************************************************************
;
;
;
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
[General]
Program_Name = NGI - ComposableTestSoftware Standalone Build Setup
; 64-bit or 32-bit. Possible values: 32 or 64
Application_Platform = 32
[Global_Settings]
Always_Run_Application_Using_Admin_Account = false
Suppress_All_Prompts = true
Provide_Windows_Password_For_Auto_Login = false
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
; This section defines all the setup steps to be performed and allow the user the option of enabling/disabling each step
; The key can be anything.
; The value must define the setup step and its associated section name separated by comma: Setup_Step,Section_Name
; Below is a list of all possible setup steps:
; CONFIGURE_NETWORK_ADAPTERS
; RUN_APPLICATIONS
; INSTALL_SOFTWARE_PACKAGES
; ENABLE_INTERNET_INFORMATION_SERVICES
; CREATE_DIRECTORIES
; CREATE_NETWORK_SHARES
; SET_ENVIRONMENT_VARIABLES
; SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS
; TRANSFER_FILE_PACKAGES
; MODIFY_WINDOWS_REGISTRY
; PROCESS_GUTS_CONFIG_FILE
; CREATE_WINDOWS_SHORTCUTS
; ASSIST_BUILDING_GUTS_APP
; REMOVE_FILES_FOLDERS
;
; The setup setup can be run more than once by creating another key and assigned the setup step to it
; Each setup step needs a section name. Section name provides all the information necessary for the setup step
; The sequence of the execution of the setup steps will be in the same order as they are specified.
; ******************************************************************************************************************************
[Setup_Step_Manager]
;step = RUN_APPLICATIONS,Extract_Software_Archives
step = INSTALL_SOFTWARE_PACKAGES,Install_Software
;step = CREATE_DIRECTORIES,Paths_Creation
;step = CREATE_NETWORK_SHARES,Paths_Sharing
;step = SET_ENVIRONMENT_VARIABLES,Env_Variables
;step = TRANSFER_FILE_PACKAGES,Files_Transfer_Packages
;step = CREATE_WINDOWS_SHORTCUTS,Windows_Shortcuts
;step = RUN_APPLICATIONS,Shut_Down_National_Instruments_Processes
;step = REMOVE_FILES_FOLDERS , Files_Folders_Removal
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to install various software application
; For each software application to be installed, 4 things can be defined:
;
; Possible keys:
; app#_name (REQUIRED. Name of the application to be installed/checked)
; app#_setup_file (OPTIONAL. Path and name of the installer)
; - the setup file can make use of macros. Look below for the available macros
; app#_setup_argument (OPTIONAL. Argument for the setup file. Usually to perform unattended install)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; app#_setup_confirm_prompt (OPTIONAL. Prompt user to confirm before installation starts.)
; - possible values: yes, no
; - yes: there will be prompt asking user confirm/refuse install
; - no: installation will start automatically ( this is the default )
; app#_exe_file (REQUIRED only if app#_hklm_reg_key is not specified.
; This is used to verify that the software successfully installed)
; app#_reg_path (REQUIRED only if app#_exe_file is not specified. Registry folder path, not including valuename)
; app#_reg_type (REQUIRED only if app#_reg_key is specified)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; app#_reg_value (REQUIRED only if app#_reg_key is specified. Registry value name's value)
; app#_reg_name (REQUIRED only if app#_reg_key is specified. Registry value name)
; app#_reg_compare (REQUIRED only if app#_reg_key is specified. Compare operator between value name's value specified here versus actual value read from registry)
; - there are only six options for this key ( eq, lt, gt, lte, gte, ne )
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; example 1:
; app1_name = Perl 5.6.1.638
; app1_setup_file = {user_temp_folder}\Installer.bat
; app1_exe_file = C:\Perl\bin\perl.exe
;
; example 2:
; app1_reg_path = SOFTWARE\National Instruments\NI-488.2\CurrentVersion
; app1_reg_type = local_machine
; app1_reg_value = 15.0
; app1_reg_name = Version
; app1_reg_compare = gte
; app1_name = National Instrument 488.2 (v15 or higher)
; app1_setup_file = C:\ni\setup.exe
;
; example 3:
; app1_exe_file = C:\Perl\bin\perl.exe
; app1_name = Perl 5.6.1.638
;
; example 4:
; app1_name = Sapera LT 8.11 (x64)
; app1_setup_file = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\Software\TeledyneDalsa\Sapera_LT_8.11_RuntimeSetup.exe
; app1_setup_argument = -s -f1"{app1_setup_file}\sapera_setup.iss"
; app1_reg_path = SOFTWARE\Teledyne DALSA\Sapera LT
; app1_reg_type = local_machine
; app1_reg_name = IsSaperaFrameGrabberSupport
;
; ******************************************************************************************************************************
; Visual Studio ClassRoot Registry Keys
;
; {"VS2005", "VisualStudio.DTE.8.0"},
; {"VS2008", "VisualStudio.DTE.9.0"},
; {"VS2010", "VisualStudio.DTE.10.0"},
; {"VS2012", "VisualStudio.DTE.11.0"},
; {"VS2013", "VisualStudio.DTE.12.0"},
; {"VS2015", "VisualStudio.DTE.13.0"}
;
; Visual Studio Redistributable Local_Machine Registry Keys
;
; {"VS2005_x64", @"SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182"},
; {"VS2005_x86", @"SOFTWARE\Classes\Installer\Products\c1c4f01781cc94c4c8fb1542c0981a2a"},
; {"VS2008_x64", @"SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D"},
; {"VS2008_x86", @"SOFTWARE\Classes\Installer\Products\6E815EB96CCE9A53884E7857C57002F0"},
; {"VS2010_x64", @"SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F"},
; {"VS2010_x86", @"SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A"},
; {"VS2012_x64", @"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}"},
; {"VS2012_x86", @"SOFTWARE\Classes\Installer\Dependencies\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}"},
; {"VS2013_x64", @"SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f}"},
; {"VS2013_x86", @"SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}"},
; {"VS2015_x64", @"SOFTWARE\Classes\Installer\Dependencies\{3ee5e5bb-b7cc-4556-8861-a00a82977d6c}"},
; {"VS2015_x86", @"SOFTWARE\Classes\Installer\Dependencies\{23daf363-3020-4059-b3ae-dc4ad39fed19}"}
;
; ******************************************************************************************************************************
[Install_Software]
app5_name = Visual Studio 2022
app5_setup_argument = -p --norestart --noweb --add Microsoft.VisualStudio.Workload.ManagedDesktop;includeRecommended Microsoft.VisualStudio.Workload.NativeDesktop;includeRecommended Microsoft.VisualStudio.Component.VC.ATLMFC Microsoft.VisualStudio.Component.VC.CLI.Support Microsoft.VisualStudio.Workload.VisualStudioExtension;includeRecommended
app5_reg_path = VisualStudio.DTE.17.0
app5_reg_type = classes_root
app5_setup_file = D:\Windows_Stuff\Visual_Studio_2022.17.9.5\vs_setup.exe
app5_install_process_name = setup
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used for enabling windows features
; Only one thing needs to be defined for this section.
; - a text file that lists windows feature name line by line
;
; Possible keys:
; feature_list_file
;
; example:
; windows_feature_list_file = .\feature_list.txt
; ******************************************************************************************************************************
[Windows_Features]
windows_feature_list_file = ..\Data\windows_feature_list.txt
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to run various applications or scripts
;
; Possible keys:
; app#_description (OPTIONAL. Describe the purpose of running this application)
; app#_path (REQUIRED. Full path and name of the application to be run)
; - the path can take advantage of using macros. Look below for the available macros
; app#_is_console (REQUIRED. Specify if the application is a console application (i.e. DOS application)
; - value is either true/false
; app#_argument (OPTIONAL. Arguments to be passed to the application)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; - sometimes, the argument maybe include equal sign in them, but we can't have equal sign
; in the value of the INI. To make it possible, if an equal sign is needed in the ini file
; use <eq> in place of =
;
; app#_argument_path# - for each of these keys, there must be a corresponding {app#_argument_path#} defined in the value of app#_argument
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; Example 1:
; app1_path = C:\ReleaseIB_Production\app.exe
; app1_arguments = -role Datasrv -suite LSPS3 -production
;
; Example 2:
; app1_description = Extracting ActivePerl archive
; app1_path = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
;
; Example 3:
; app1_description = Extracting ActivePerl archive
; app1_path = {cd_drive}\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
; ******************************************************************************************************************************
[Extract_Software_Archives]
;app1_description = Extracting Visual Studio 2012 archive
;app1_cd_label = GUTS Support Appz 1/2
;app1_path = {cd_drive}\DISK1\7-Zip\7z.exe
;app1_is_console = true
;app1_argument = x "{cd_drive}\DISK1\msvs2012.7z" -o"{user_temp_folder}\vs2012" -y
;
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Modify Network Adapter's settings
;
; Possible keys:
; nic#_pci_location ( REQUIRED.)
; - the value must be in the form of: #,#,# ( bus, device, function)
; i.e.: 0,25,0 - bus = 0, device = 25, function = 0
; nic#_adapter_name (OPTIONAL. Set the name of the network adapter)
; nic#_ip_and_subnet (OPTIONAL. Set ip address and subnet mask of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,255.255.255.0
; nic#_default_gateway# (OPTIONAL. Default gateway of the network adapter)
; - the value must be in the form of: #.#.#.#
; i.e.: 192.168.0.1
; nic#_dns_servers (OPTIONAL. Set DNS servers of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,192.168.0.11
; nic#_link_speed (OPTIONAL. Set the link speed of the network adapter)
; - Before using this option. Make sure that the network adapter supports link speed setting
; This is really a registry change for the network adapter. The registry name is *SpeedDuplex
; The value for *SpeedDuplex is usually a digit ranging from 0-5.
; Here's an example:
; 0 - Auto Negotiate
; 1 - 10Mbps Half Duplex
; 2 - 10Mbps Full Duplex
; 3 - 100Mpbs Half Duplex
; 4 - 100Mbps Full Duplex
; 6 - 1Gpbs Full Duplex
; There's no 5 defined because there's no 1Gpbs Half Duplex
; IMPORTANT: The above example was taken from a Intel network card. These numbers could
; mean something else different from one network card to the next. Refer to the network
; adapter's manufacturer manual for the actual numbers and their meanings.
;
; nic#_enable_dhcp (OPTIONAL. Set network adapter to use DHCP)
; - the value must be either: true/false
; - if this is set to true, all the other settings above, except link speed, will be ignored
; this will effectively set IP and DNS Servers to be obtained automatically
;
; Example 1:
; nic1_pci_location = 0,25, 0
; nic1_link_speed = 2
; nic1_adapter_name = My Connection
; nic1_enable_dhcp = false
; nic1_ip_and_subnet = 192.168.0.10 , 255.255.255.0
; nic1_default_gateway = 192.168.0.1
; nic1_dns_servers = 192.168.0.5, 192.168.0.6
;
; ******************************************************************************************************************************
[Network_Interface_Cards]
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to remove/delete various files or folders
;
; Possible keys:
; item (REQUIRED. This is either a file or folder to be removed)
;
; If the item is a folder, user has the option to specify whether or not to delete the folder recursively. To specify to delete
; a folder recursively, add the word "recursive" right after the path separated by a comma
;
; The path can also include user desktop path or temporary folder
; for desktop path, use macro: {user_desktop}
; for temporary folder, use macro: {user_temp_folder}
;
; Example 1 - Delete a file:
; item = A:\test\test.hpp
;
; Example 2 - Delete a folder recursively:
; item = A:\test\test2,recursive
;
; Example 3 - Delete only the files contained in the folder:
; item = A:\test\test2
;
; Example 4 - Delete a folder on the user's desktop:
; item = {user_desktop}\test2
;
; Example 5 - Delete a folder in the user's temporary folder
; item = {user_temp_folder}\test2
; ******************************************************************************************************************************
[Files_Folders_Removal]
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to copy various packages of files from a source location to destination location
; Each XML file contains at least 1 package of files. Each file has a source and destination locations
; Key name can be anything
; Value must a be a path to a XML file
;
; example 1:
; file_package = package1.xml
; ******************************************************************************************************************************
[Files_Transfer_Packages]
file_package = ..\CTS\file_package.xml
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Specify all the paths to be created
; Possible keys:
; path (REQUIRED. Valid path to be created)
;
; example:
; path1 = C:\DataIIB\data\Block_IB\CV
; path2 = C:\DataIIB\data\Block_IB\General\Logs
; ******************************************************************************************************************************
[Paths_Creation]
path = C:\ReleaseIB_Engineering\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; To share a folder, must provide path to a folder.
; Share names are optional as the folder name will be used as the default share name.
; Any share name defined here will be used as additional share name for its corresponding folder
; The # in "path#" must match in both keys. A folder can have more than one share name.
; Possible keys:
; path# (OPTIONAL. A valid path to be shared)
; path#_additional_share_names (OPTIONAL. Additional share names associated with a path)
; - Define one or more shares names separated by comma
; path#_allowed_accounts ( Windows Built-In, local or domain accounts to be added to the permission list for this share with Full Control )
; - if this is not defined, this network share will be accessible to everyone with Full Control
; - if defined, the value must be in the following format:
; User1,User2,User3 (if more than one account is defined, separate by comma)
; The account name must either be a built-in window account or local/domain account
; if the account name is a built-in window account, it can only be one of the following:
; - everyone, authenticated users
; if the account name is a local/domain account it must be in this format: DOMAIN\UserAccountName
;
; example:
; path1 = C:\DataIIB\
; path1_additional_share_names = DataIIB1, DataIIB2
; path1_allowed_accounts = Authenticated Users,US\1117637
; path2 = C:\DataIA
; path2__additional_share_names = DataIA_1
; path2_allowed_accounts = MYCOMPUTERNAME\Duc
; path3 = C:\DataIC
; ******************************************************************************************************************************
[Paths_Sharing]
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create windows system environment variables
; the key would be the system environment variable name.
;
; Note:
; Any key defined here will have its valued replaced, except for "path" because path is a window's system environment variable
; If a key's name is path, the value specified will be appendeding to existing value
;
; path can have one or more values separated by commas
; Example:
; path = C:\folder1
; path = C:\folder1, C:\folder2
; ******************************************************************************************************************************
[Env_Variables]
SM3_SEEKER = C:\Development\GUTS\SM3
; the address of the computer where all the data of each test is saved before being pushed to the network
SM3_SKR_SERVER = localhost
; the address of the computer where all test data are pushed to after testing
SM3_SKR_NETWORK = localhost
path = C:\Perl\bin\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Add/Modify or Delete registry's key
;
; Possible keys:
; reg#_action ( REQUIRED. What action to perform)
; - there are only 2 actions ( add/modify, delete)
; reg#_path (REQUIRED. Registry folder path, not including valuename)
; reg#_type (REQUIRED)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; reg#_name_value_pair# (Optional. Registry name values and their names)
; - the registry key defined by registry path can have multiple value names and their associated values
; - Format of the value: [name:***,value:***,type:***] - replace *** with actual text
; - name can be anything
; - value is either numeric or alphanumeric depending on type
; - type can only be 1 of 4: string, multi_string, dword, qword
; If type is dword or qword then value can only be numeric
; If type is multi-string, then format of the value must be:
; [name:***,:value:***:value:***...,type:multi_string]
;
; Example 1:
; reg1_action = add/modify
; reg1_path = SOFTWARE\MySoftware\
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version,value:3,type:string]
; reg1_name_value_pair2 = [name:Version2,:value:3:value:34,type:multi-string]
;
; Example 2:
; reg1_action = add/modify
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
;
; Example3:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version]
;
; Example4:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; ******************************************************************************************************************************
[Windows_Registry]
;reg1_action = delete
;reg1_path = SOFTWARE\Duc\
;reg1_type = local_machine
;reg1_name_value_pairs = Versionn[:]3[,]ginrl[:]boy
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create shortcuts on the user's desktop
;
; example:
; shortcut1_name = Data Server
; shortcut1_target_path = C:\ReleaseIB_Production\app.exe
; shortcut1_arguments = -role datasrv -suite lsps3 -production
; ******************************************************************************************************************************
[Windows_Shortcuts]

View File

@@ -0,0 +1,599 @@
; ************************************************* SM3 CONFIGURATION FILE *****************************************************
; Description:
; This is an INI file which contains the configuration information for the automated setup of either an
; ENGINEERING or PRODUCTION environment for developing or running SM3 GUTS (Guidance Unit Test Software)
;
; Author: Duc Le
;
; ******************************************************************************************************************************
;
;
;
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
[General]
Program_Name = SM3 Block IB - Control PC
; 64-bit or 32-bit. Possible values: 32 or 64
Application_Platform = 32
[Global_Settings]
Always_Run_Application_Using_Admin_Account = true
Suppress_All_Prompts = true
Provide_Windows_Password_For_Auto_Login = false
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
; This section defines all the setup steps to be performed and allow the user the option of enabling/disabling each step
; The key can be anything.
; The value must define the setup step and its associated section name separated by comma: Setup_Step,Section_Name
; Below is a list of all possible setup steps:
; CONFIGURE_NETWORK_ADAPTERS
; RUN_APPLICATIONS
; INSTALL_SOFTWARE_PACKAGES
; ENABLE_INTERNET_INFORMATION_SERVICES
; CREATE_DIRECTORIES
; CREATE_NETWORK_SHARES
; SET_ENVIRONMENT_VARIABLES
; SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS
; TRANSFER_FILE_PACKAGES
; MODIFY_WINDOWS_REGISTRY
; PROCESS_GUTS_CONFIG_FILE
; CREATE_WINDOWS_SHORTCUTS
; ASSIST_BUILDING_GUTS_APP
; REMOVE_FILES_FOLDERS
;
; The setup setup can be run more than once by creating another key and assigned the setup step to it
; Each setup step needs a section name. Section name provides all the information necessary for the setup step
; The sequence of the execution of the setup steps will be in the same order as they are specified.
; ******************************************************************************************************************************
[Setup_Step_Manager]
step = INSTALL_SOFTWARE_PACKAGES,Install_VS2012
step = INSTALL_SOFTWARE_PACKAGES,Install_VS2012_Update4
step = INSTALL_SOFTWARE_PACKAGES,Install_4882
step = INSTALL_SOFTWARE_PACKAGES,Install_VXI
step = INSTALL_SOFTWARE_PACKAGES,Install_Perl
step = INSTALL_SOFTWARE_PACKAGES,Install_Redist2013
step = RUN_APPLICATIONS,Enable_Network_Sharing
step = CREATE_DIRECTORIES,Paths_Creation
step = CREATE_NETWORK_SHARES,Paths_Sharing
step = SET_ENVIRONMENT_VARIABLES,Env_Variables
step = TRANSFER_FILE_PACKAGES,Files_Transfer_Packages
step = MODIFY_WINDOWS_REGISTRY,Windows_Registry
step = CONFIGURE_NETWORK_ADAPTERS,Network_Interface_Cards
step = CREATE_WINDOWS_SHORTCUTS,Windows_Shortcuts
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to install various software application
; For each software application to be installed, 4 things can be defined:
;
; Possible keys:
; app#_name (REQUIRED. Name of the application to be installed/checked)
; app#_setup_file (OPTIONAL. Path and name of the installer)
; - the setup file can make use of macros. Look below for the available macros
; app#_setup_argument (OPTIONAL. Argument for the setup file. Usually to perform unattended install)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; app#_setup_confirm_prompt (OPTIONAL. Prompt user to confirm before installation starts.)
; - possible values: yes, no
; - yes: there will be prompt asking user confirm/refuse install
; - no: installation will start automatically ( this is the default )
; app#_exe_file (REQUIRED only if app#_hklm_reg_key is not specified.
; This is used to verify that the software successfully installed)
; app#_reg_path (REQUIRED only if app#_exe_file is not specified. Registry folder path, not including valuename)
; app#_reg_type (REQUIRED only if app#_reg_key is specified)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; app#_reg_value (REQUIRED only if app#_reg_key is specified. Registry value name's value)
; app#_reg_name (REQUIRED only if app#_reg_key is specified. Registry value name)
; app#_reg_compare (REQUIRED only if app#_reg_key is specified. Compare operator between value name's value specified here versus actual value read from registry)
; - there are only six options for this key ( eq, lt, gt, lte, gte, ne )
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; example 1:
; app1_name = Perl 5.6.1.638
; app1_setup_file = {user_temp_folder}\Installer.bat
; app1_exe_file = C:\Perl\bin\perl.exe
;
; example 2:
; app1_reg_path = SOFTWARE\National Instruments\NI-488.2\CurrentVersion
; app1_reg_type = local_machine
; app1_reg_value = 15.0
; app1_reg_name = Version
; app1_reg_compare = gte
; app1_name = National Instrument 488.2 (v15 or higher)
; app1_setup_file = C:\ni\setup.exe
;
; example 3:
; app1_exe_file = C:\Perl\bin\perl.exe
; app1_name = Perl 5.6.1.638
;
; example 4:
; app1_name = Sapera LT 8.11 (x64)
; app1_setup_file = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\Software\TeledyneDalsa\Sapera_LT_8.11_RuntimeSetup.exe
; app1_setup_argument = -s -f1"{app1_setup_file}\sapera_setup.iss"
; app1_reg_path = SOFTWARE\Teledyne DALSA\Sapera LT
; app1_reg_type = local_machine
; app1_reg_name = IsSaperaFrameGrabberSupport
;
; ******************************************************************************************************************************
; Visual Studio ClassRoot Registry Keys
;
; {"VS2005", "VisualStudio.DTE.8.0"},
; {"VS2008", "VisualStudio.DTE.9.0"},
; {"VS2010", "VisualStudio.DTE.10.0"},
; {"VS2012", "VisualStudio.DTE.11.0"},
; {"VS2013", "VisualStudio.DTE.12.0"},
; {"VS2015", "VisualStudio.DTE.13.0"}
;
; Visual Studio Redistributable Local_Machine Registry Keys
;
; {"VS2005_x64", @"SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182"},
; {"VS2005_x86", @"SOFTWARE\Classes\Installer\Products\c1c4f01781cc94c4c8fb1542c0981a2a"},
; {"VS2008_x64", @"SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D"},
; {"VS2008_x86", @"SOFTWARE\Classes\Installer\Products\6E815EB96CCE9A53884E7857C57002F0"},
; {"VS2010_x64", @"SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F"},
; {"VS2010_x86", @"SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A"},
; {"VS2012_x64", @"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}"},
; {"VS2012_x86", @"SOFTWARE\Classes\Installer\Dependencies\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}"},
; {"VS2013_x64", @"SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f}"},
; {"VS2013_x86", @"SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}"},
; {"VS2015_x64", @"SOFTWARE\Classes\Installer\Dependencies\{3ee5e5bb-b7cc-4556-8861-a00a82977d6c}"},
; {"VS2015_x86", @"SOFTWARE\Classes\Installer\Dependencies\{23daf363-3020-4059-b3ae-dc4ad39fed19}"}
;
; ******************************************************************************************************************************
[Install_VS2012]
app5_name = Visual Studio 2012
app5_setup_argument = /passive /norestart
app5_reg_path = VisualStudio.DTE.11.0
app5_reg_type = classes_root
app5_setup_file = ..\Data\software\Visual_Studio_2012\vs_professional.exe
[Install_VS2012_Update4]
app6_name = Visual Studio 2012 - Update 4
app6_setup_file = ..\Data\software\Visual_Studio_2012_Update_4\VS2012.4.exe
app6_setup_argument = /passive /norestart
app6_reg_path = SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\11.0\CompilerCore\1033
app6_reg_type = local_machine
app6_reg_value = 11.0.61030
app6_reg_name = UpdateVersion
app6_reg_compare = eq
[Install_4882]
app2_name = National Instrument 488.2 (ver. 17)
app2_setup_file = ..\Data\software\NI_4882_v17\setup.exe
app2_setup_argument = /qb /r:n /AcceptLicenses yes
app2_reg_display_name = NI-488.2 17.0
app2_reg_type = local_machine
app2_reg_value = 17
app2_reg_name = DisplayVersion
app2_reg_compare = gte
app2_reboot_computer_at_completion = yes
app2_exit_codes_to_ignore = 3010
[Install_VXI]
app3_name = National Instrument VXI (ver. 16)
app3_setup_file = ..\Data\software\NI_VXI_v17\setup.exe
app3_setup_argument = /qb /r:n /AcceptLicenses yes
app3_reg_display_name = NI-VXI 16.0
app3_reg_type = local_machine
app3_reg_value = 16
app3_reg_name = DisplayVersion
app3_reg_compare = gte
app3_reboot_computer_at_completion = yes
app3_exit_codes_to_ignore = 3010
[Install_Perl]
;app1_setup_confirm_prompt = yes
app1_name = ActivePerl 5.6.1.638
app1_setup_file = ..\Data\software\Perl_5_6\Installer_Silent.bat
app1_exe_file = C:\Perl\bin\perl.exe
[Install_Redist2013]
app4_name = Visual Studio Redistributable 2013 (x86)
app4_setup_file = ..\Data\software\VS2013_Redistributable\vcredist_x86.EXE
app4_setup_argument = /install /passive /norestart
app4_reg_path = SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}
app4_reg_type = local_machine
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used for enabling windows features
; Only one thing needs to be defined for this section.
; - a text file that lists windows feature name line by line
;
; Possible keys:
; feature_list_file
;
; example:
; windows_feature_list_file = .\feature_list.txt
; ******************************************************************************************************************************
[Windows_Features]
windows_feature_list_file = .\Repository\windows_feature_list.txt
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to run various applications or scripts
;
; Possible keys:
; app#_description (OPTIONAL. Describe the purpose of running this application)
; app#_path (REQUIRED. Full path and name of the application to be run)
; - the path can take advantage of using macros. Look below for the available macros
; app#_is_console (REQUIRED. Specify if the application is a console application (i.e. DOS application)
; - value is either true/false
; app#_argument (OPTIONAL. Arguments to be passed to the application)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; - sometimes, the argument maybe include equal sign in them, but we can't have equal sign
; in the value of the INI. To make it possible, if an equal sign is needed in the ini file
; use <eq> in place of =
;
; app#_argument_path# - for each of these keys, there must be a corresponding {app#_argument_path#} defined in the value of app#_argument
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; Example 1:
; app1_path = C:\ReleaseIB_Production\app.exe
; app1_arguments = -role Datasrv -suite LSPS3 -production
;
; Example 2:
; app1_description = Extracting ActivePerl archive
; app1_path = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
;
; Example 3:
; app1_description = Extracting ActivePerl archive
; app1_path = {cd_drive}\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
; ******************************************************************************************************************************
[Enable_Network_Sharing]
app3_description = Enabling Network Discovery
app3_path = c:\windows\system32\netsh.exe
app3_is_console = true
app3_argument = advfirewall firewall set rule group<eq>"Network Discovery" new enable<eq>Yes
app4_description = Enabling File and Printer Sharing
app4_path = c:\windows\system32\netsh.exe
app4_is_console = true
app4_argument = advfirewall firewall set rule group<eq>"File and Printer Sharing" new enable<eq>Yes
[Extract_Software_Archives]
app1_description = Extracting Visual Studio 2012 archive
app1_cd_label = GUTS Support Appz 1/2
app1_path = {cd_drive}\DISK1\7-Zip\7z.exe
app1_is_console = true
app1_argument = x "{cd_drive}\DISK1\msvs2012.7z" -o"{user_temp_folder}\vs2012" -y
app2_description = Extracting Visual Studio 2012 Update 4 archive
app2_cd_label = GUTS Support Appz 1/2
app2_path = {cd_drive}\DISK1\7-Zip\7z.exe
app2_is_console = true
app2_argument = x "{cd_drive}\DISK1\msvs2012_update4.7z" -o"{user_temp_folder}\vs2012_update4" -y
app3_description = Extracting NI 488.2 archive
app3_cd_label = GUTS Support Appz 1/2
app3_path = {cd_drive}\DISK1\7-Zip\7z.exe
app3_is_console = true
app3_argument = x "{cd_drive}\DISK1\ni4882.7z" -o"{user_temp_folder}\ni4882" -y
app4_description = Extracting NI VXI archive
app4_cd_label = GUTS Support Appz 1/2
app4_path = {cd_drive}\DISK1\7-Zip\7z.exe
app4_is_console = true
app4_argument = x "{cd_drive}\DISK1\nivxi.7z" -o"{user_temp_folder}\nivxi" -y
app5_description = Extracting ActivePerl archive
app5_cd_label = GUTS Support Appz 1/2
app5_path = {cd_drive}\DISK1\7-Zip\7z.exe
app5_is_console = true
app5_argument = x "{cd_drive}\DISK1\Perl.7z" -o"{user_temp_folder}" -y
[Shut_Down_National_Instruments_Processes]
app1_description = Killing process nierserver.exe
app1_path = C:\Windows\system32\taskkill.exe
app1_is_console = true
app1_argument = /f /im nierserver.exe
;
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Modify Network Adapter's settings
;
; Possible keys:
; nic#_pci_location ( REQUIRED.)
; - the value must be in the form of: #,#,# ( bus, device, function)
; i.e.: 0,25,0 - bus = 0, device = 25, function = 0
; nic#_adapter_name (OPTIONAL. Set the name of the network adapter)
; nic#_ip_and_subnet (OPTIONAL. Set ip address and subnet mask of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,255.255.255.0
; nic#_default_gateway# (OPTIONAL. Default gateway of the network adapter)
; - the value must be in the form of: #.#.#.#
; i.e.: 192.168.0.1
; nic#_dns_servers (OPTIONAL. Set DNS servers of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,192.168.0.11
; nic#_link_speed (OPTIONAL. Set the link speed of the network adapter)
; - Before using this option. Make sure that the network adapter supports link speed setting
; This is really a registry change for the network adapter. The registry name is *SpeedDuplex
; The value for *SpeedDuplex is usually a digit ranging from 0-5.
; Here's an example:
; 0 - Auto Negotiate
; 1 - 10Mbps Half Duplex
; 2 - 10Mbps Full Duplex
; 3 - 100Mpbs Half Duplex
; 4 - 100Mbps Full Duplex
; 6 - 1Gpbs Full Duplex
; There's no 5 defined because there's no 1Gpbs Half Duplex
; IMPORTANT: The above example was taken from a Intel network card. These numbers could
; mean something else different from one network card to the next. Refer to the network
; adapter's manufacturer manual for the actual numbers and their meanings.
;
; nic#_enable_dhcp (OPTIONAL. Set network adapter to use DHCP)
; - the value must be either: true/false
; - if this is set to true, all the other settings above, except link speed, will be ignored
; this will effectively set IP and DNS Servers to be obtained automatically
;
; Example 1:
; nic1_pci_location = 0,25, 0
; nic1_link_speed = 2
; nic1_adapter_name = My Connection
; nic1_enable_dhcp = false
; nic1_ip_and_subnet = 192.168.0.10 , 255.255.255.0
; nic1_default_gateway = 192.168.0.1
; nic1_dns_servers = 192.168.0.5, 192.168.0.6
;
; ******************************************************************************************************************************
[Network_Interface_Cards]
nic1_pci_location = 20,0,0
nic1_adapter_name = Private_top
nic1_ip_and_subnet = 192.168.1.12 , 255.255.255.0
nic2_pci_location = 20,0,1
nic2_adapter_name = Public_bottom
nic2_enable_dhcp = true
nic3_pci_location = 5,0,0
nic3_adapter_name = Spare_side_port
nic3_enable_dhcp = true
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to remove/delete various files or folders
;
; Possible keys:
; item (REQUIRED. This is either a file or folder to be removed)
;
; If the item is a folder, user has the option to specify whether or not to delete the folder recursively. To specify to delete
; a folder recursively, add the word "recursive" right after the path separated by a comma
;
; The path can also include user desktop path or temporary folder
; for desktop path, use macro: {user_desktop}
; for temporary folder, use macro: {user_temp_folder}
;
; Example 1 - Delete a file:
; item = A:\test\test.hpp
;
; Example 2 - Delete a folder recursively:
; item = A:\test\test2,recursive
;
; Example 3 - Delete only the files contained in the folder:
; item = A:\test\test2
;
; Example 4 - Delete a folder on the user's desktop:
; item = {user_desktop}\test2
;
; Example 5 - Delete a folder in the user's temporary folder
; item = {user_temp_folder}\test2
; ******************************************************************************************************************************
[Files_Folders_Removal]
item = {user_temp_folder}\perl,recursive
item = {user_temp_folder}\vs2012,recursive
item = {user_temp_folder}\vs2012_update4,recursive
item = {user_temp_folder}\ni4882,recursive
item = {user_temp_folder}\nivxi,recursive
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to copy various packages of files from a source location to destination location
; Each XML file contains at least 1 package of files. Each file has a source and destination locations
; Key name can be anything
; Value must a be a path to a XML file
;
; example 1:
; file_package = package1.xml
; ******************************************************************************************************************************
[Files_Transfer_Packages]
file_package = ..\Data\software\control_pc_software_package.xml
file_package = ..\Data\support_files\control_pc_support_package.xml
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Specify all the paths to be created
; Possible keys:
; path (REQUIRED. Valid path to be created)
;
; example:
; path = C:\DataIIB\data\Block_IB\CV
; path = C:\DataIIB\data\Block_IB\General\Logs
; ******************************************************************************************************************************
[Paths_Creation]
path = D:\ReleaseIB_Engineering\
path = D:\ReleaseIB_Production\
path = D:\Development
path = D:\DataIB\data\Block_IB\CV
path = D:\DataIB\data\Block_IB\General\Logs
path = D:\DataIB\data\Block_IB\General\Scripts
path = D:\DataIB\data\Block_IB\General\Temp\SingleStepScript
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; To share a folder, must provide path to a folder.
; Share names are optional as the folder name will be used as the default share name.
; Any share name defined here will be used as additional share name for its corresponding folder
; The # in "path#" must match in both keys. A folder can have more than one share name.
; Possible keys:
; path# (OPTIONAL. A valid path to be shared)
; path#_additional_share_names (OPTIONAL. Additional share names associated with a path)
; - Define one or more shares names separated by comma
; path#_allowed_accounts ( Windows Built-In, local or domain accounts to be added to the permission list for this share with Full Control )
; - if this is not defined, this network share will be accessible to everyone with Full Control
; - if defined, the value must be in the following format:
; User1,User2,User3 (if more than one account is defined, separate by comma)
; The account name must either be a built-in window account or local/domain account
; if the account name is a built-in window account, it can only be one of the following:
; - everyone, authenticated users
; if the account name is a local/domain account it must be in this format: DOMAIN\UserAccountName
;
; example:
; path1 = C:\DataIIB\
; path1_additional_share_names = DataIIB1, DataIIB2
; path1_allowed_accounts = Authenticated Users,US\1117637
; path2 = C:\DataIA
; path2__additional_share_names = DataIA_1
; path2_allowed_accounts = MYCOMPUTERNAME\Duc
; path3 = C:\DataIC
; ******************************************************************************************************************************
[Paths_Sharing]
path1 = D:\ReleaseIB_Engineering\
path1_allowed_accounts = Authenticated Users
path2 = D:\DataIB\
path2_allowed_accounts = Authenticated Users
path3 = D:\ReleaseIB_Production\
path3_allowed_accounts = Authenticated Users
path4 = D:\Development\
path4_allowed_accounts = Authenticated Users
path5 = C:\
path5_allowed_accounts = Authenticated Users
path6 = D:\
path6_allowed_accounts = Authenticated Users
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create windows system environment variables
; the key would be the system environment variable name.
;
; Note:
; Any key defined here will have its valued replaced, except for "path" because path is a window's system environment variable
; If a key's name is path, the value specified will be appending to existing value
;
; path can have one or more values separated by commas
; Example:
; path = C:\folder1
; path = C:\folder1, C:\folder2
; ******************************************************************************************************************************
[Env_Variables]
; the address of the computer where all the data of each test is saved before being pushed to the network
SM3_SKR_SERVER = ste_control_local
; the address of the computer where all test data are pushed to after testing
SM3_SKR_NETWORK = sm3na02
path = C:\Perl\bin\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Add/Modify or Delete registry's key
;
; Possible keys:
; reg#_action ( REQUIRED. What action to perform)
; - there are only 2 actions ( add/modify, delete)
; reg#_path (REQUIRED. Registry folder path, not including valuename)
; reg#_type (REQUIRED)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; reg#_name_value_pair# (Optional. Registry name values and their names)
; - the registry key defined by registry path can have multiple value names and their associated values
; - Format of the value: [name:***,value:***,type:***] - replace *** with actual text
; - name can be anything
; - value is either numeric or alphanumeric depending on type
; - type can only be 1 of 4: string, multi_string, dword, qword
; If type is dword or qword then value can only be numeric
; If type is multi-string, then format of the value must be:
; [name:***,:value:***:value:***...,type:multi_string]
;
; Example 1:
; reg1_action = add/modify
; reg1_path = SOFTWARE\MySoftware\
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version,value:3,type:string]
; reg1_name_value_pair2 = [name:Version2,:value:3:value:34,type:multi-string]
;
; Example 2:
; reg1_action = add/modify
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
;
; Example3:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version]
;
; Example4:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; ******************************************************************************************************************************
[Windows_Registry]
reg1_action = add/modify
reg1_path = SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
reg1_type = local_machine
reg1_name_value_pair1 = [name:BackConnectionHostNames,:value:ste_control_local,type:multi_string]
reg2_action = add/modify
reg2_path = SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
reg2_type = local_machine
reg2_name_value_pair1 = [name:DisableStrictNameChecking,value:1,type:dword]
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create shortcuts on the user's desktop
;
; example:
; shortcut1_name = Data Server
; shortcut1_target_path = C:\ReleaseIB_Production\app.exe
; shortcut1_arguments = -role datasrv -suite lsps3 -production
; ******************************************************************************************************************************
[Windows_Shortcuts]
shortcut1_name = GUTS Startup
shortcut1_target_path = C:\Perl\bin\perl.exe
shortcut1_arguments = D:\ReleaseIB_Production\startup.pl
shortcut1_for_all_users = true
shortcut2_name = WidebandAccount
shortcut2_target_path = D:\ReleaseIB_Production\WidebandAccount.bat
shortcut2_for_all_users = true
shortcut3_name = Resman
shortcut3_target_path = C:\Program Files (x86)\National Instruments\VXI\Resman.exe
shortcut3_for_all_users = true

View File

@@ -0,0 +1,596 @@
; ************************************************* SM3 CONFIGURATION FILE *****************************************************
; Description:
; This is an INI file which contains the configuration information for the automated setup of either an
; ENGINEERING or PRODUCTION environment for developing or running SM3 GUTS (Guidance Unit Test Software)
;
; Author: Duc Le
;
; ******************************************************************************************************************************
;
;
;
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
[General]
Program_Name = SM3 Block IB - Dev PC
; 64-bit or 32-bit. Possible values: 32 or 64
Application_Platform = 32
[Global_Settings]
Always_Run_Application_Using_Admin_Account = true
Suppress_All_Prompts = true
Provide_Windows_Password_For_Auto_Login = false
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
; This section defines all the setup steps to be performed and allow the user the option of enabling/disabling each step
; The key can be anything.
; The value must define the setup step and its associated section name separated by comma: Setup_Step,Section_Name
; Below is a list of all possible setup steps:
; CONFIGURE_NETWORK_ADAPTERS
; RUN_APPLICATIONS
; INSTALL_SOFTWARE_PACKAGES
; ENABLE_INTERNET_INFORMATION_SERVICES
; CREATE_DIRECTORIES
; CREATE_NETWORK_SHARES
; SET_ENVIRONMENT_VARIABLES
; SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS
; TRANSFER_FILE_PACKAGES
; MODIFY_WINDOWS_REGISTRY
; PROCESS_GUTS_CONFIG_FILE
; CREATE_WINDOWS_SHORTCUTS
; ASSIST_BUILDING_GUTS_APP
; REMOVE_FILES_FOLDERS
;
; The setup setup can be run more than once by creating another key and assigned the setup step to it
; Each setup step needs a section name. Section name provides all the information necessary for the setup step
; The sequence of the execution of the setup steps will be in the same order as they are specified.
; ******************************************************************************************************************************
[Setup_Step_Manager]
step = RUN_APPLICATIONS,Import_Trusted_Publisher_Certificates
step = INSTALL_SOFTWARE_PACKAGES,Install_VS2012
step = INSTALL_SOFTWARE_PACKAGES,Install_VS2012_Update4
step = INSTALL_SOFTWARE_PACKAGES,Install_Sapera
step = INSTALL_SOFTWARE_PACKAGES,Install_PX4_Driver
step = INSTALL_SOFTWARE_PACKAGES,Install_LabWindows_CVI
step = RUN_APPLICATIONS,Enable_Network_Sharing
step = CREATE_DIRECTORIES,Paths_Creation
step = CREATE_NETWORK_SHARES,Paths_Sharing
step = MODIFY_WINDOWS_REGISTRY,Windows_Registry
step = CONFIGURE_NETWORK_ADAPTERS,Network_Interface_Cards
step = TRANSFER_FILE_PACKAGES,Files_Transfer_Packages
step = CREATE_WINDOWS_SHORTCUTS,Windows_Shortcuts
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to install various software application
; For each software application to be installed, 4 things can be defined:
;
; Possible keys:
; app#_name (REQUIRED. Name of the application to be installed/checked)
; app#_setup_file (OPTIONAL. Path and name of the installer)
; - the setup file can make use of macros. Look below for the available macros
; app#_setup_argument (OPTIONAL. Argument for the setup file. Usually to perform unattended install)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; app#_setup_confirm_prompt (OPTIONAL. Prompt user to confirm before installation starts.)
; - possible values: yes, no
; - yes: there will be prompt asking user confirm/refuse install
; - no: installation will start automatically ( this is the default )
; app#_exe_file (REQUIRED only if app#_hklm_reg_key is not specified.
; This is used to verify that the software successfully installed)
; app#_reg_path (REQUIRED only if app#_exe_file is not specified. Registry folder path, not including valuename)
; app#_reg_type (REQUIRED only if app#_reg_key is specified)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; app#_reg_value (REQUIRED only if app#_reg_key is specified. Registry value name's value)
; app#_reg_name (REQUIRED only if app#_reg_key is specified. Registry value name)
; app#_reg_compare (REQUIRED only if app#_reg_key is specified. Compare operator between value name's value specified here versus actual value read from registry)
; - there are only six options for this key ( eq, lt, gt, lte, gte, ne )
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; example 1:
; app1_name = Perl 5.6.1.638
; app1_setup_file = {user_temp_folder}\Installer.bat
; app1_exe_file = C:\Perl\bin\perl.exe
;
; example 2:
; app1_reg_path = SOFTWARE\National Instruments\NI-488.2\CurrentVersion
; app1_reg_type = local_machine
; app1_reg_value = 15.0
; app1_reg_name = Version
; app1_reg_compare = gte
; app1_name = National Instrument 488.2 (v15 or higher)
; app1_setup_file = C:\ni\setup.exe
;
; example 3:
; app1_exe_file = C:\Perl\bin\perl.exe
; app1_name = Perl 5.6.1.638
;
; example 4:
; app1_name = Sapera LT 8.11 (x64)
; app1_setup_file = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\Software\TeledyneDalsa\Sapera_LT_8.11_RuntimeSetup.exe
; app1_setup_argument = -s -f1"{app1_setup_file}\sapera_setup.iss"
; app1_reg_path = SOFTWARE\Teledyne DALSA\Sapera LT
; app1_reg_type = local_machine
; app1_reg_name = IsSaperaFrameGrabberSupport
;
; ******************************************************************************************************************************
; Visual Studio ClassRoot Registry Keys
;
; {"VS2005", "VisualStudio.DTE.8.0"},
; {"VS2008", "VisualStudio.DTE.9.0"},
; {"VS2010", "VisualStudio.DTE.10.0"},
; {"VS2012", "VisualStudio.DTE.11.0"},
; {"VS2013", "VisualStudio.DTE.12.0"},
; {"VS2015", "VisualStudio.DTE.13.0"}
;
; Visual Studio Redistributable Local_Machine Registry Keys
;
; {"VS2005_x64", @"SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182"},
; {"VS2005_x86", @"SOFTWARE\Classes\Installer\Products\c1c4f01781cc94c4c8fb1542c0981a2a"},
; {"VS2008_x64", @"SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D"},
; {"VS2008_x86", @"SOFTWARE\Classes\Installer\Products\6E815EB96CCE9A53884E7857C57002F0"},
; {"VS2010_x64", @"SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F"},
; {"VS2010_x86", @"SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A"},
; {"VS2012_x64", @"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}"},
; {"VS2012_x86", @"SOFTWARE\Classes\Installer\Dependencies\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}"},
; {"VS2013_x64", @"SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f}"},
; {"VS2013_x86", @"SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}"},
; {"VS2015_x64", @"SOFTWARE\Classes\Installer\Dependencies\{3ee5e5bb-b7cc-4556-8861-a00a82977d6c}"},
; {"VS2015_x86", @"SOFTWARE\Classes\Installer\Dependencies\{23daf363-3020-4059-b3ae-dc4ad39fed19}"}
;
; ******************************************************************************************************************************
[Install_VS2012]
app1_name = Visual Studio 2012
app1_setup_argument = /passive /norestart
app1_reg_path = VisualStudio.DTE.11.0
app1_reg_type = classes_root
app1_setup_file = ..\Data\software\Visual_Studio_2012\vs_professional.exe
[Install_VS2012_Update4]
app2_name = Visual Studio 2012 - Update 4
app2_setup_file = ..\Data\software\Visual_Studio_2012_Update_4\\VS2012.4.exe
app2_setup_argument = /passive /norestart
app2_reg_path = SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\11.0\CompilerCore\1033
app2_reg_type = local_machine
app2_reg_value = 11.0.61030
app2_reg_name = UpdateVersion
app2_reg_compare = eq
[Install_Sapera]
app3_name = Sapera LT 8.11 (x64)
app3_setup_argument = -s -f1"{app3_setup_file}\sapera_setup.iss"
app3_setup_file = ..\Data\software\SaperaLT_Runtime_8_11\Sapera_LT_8.11_RuntimeSetup.exe
app3_reg_display_name = Teledyne DALSA Sapera LT Runtime 8.11.00.1621 (Frame grabbers and CameraLink cameras)
app3_reg_type = local_machine
app3_reg_value = 8.11
app3_reg_name = DisplayVersion
app3_reg_compare = gte
app3_reboot_computer_at_completion = yes
[Install_PX4_Driver]
app4_name = Xcelera-LVDS PX4 Device Driver (x64)
app4_setup_argument = -s -f1"{app4_setup_file}\px4_setup.iss"
app4_setup_file = ..\Data\software\TeledyneDalsa_FrameGrabber\X64_Xcelera-LVDS_PX4_1.10.01.0223.exe
app4_reg_path = SOFTWARE\Teledyne DALSA\X64 Xcelera-LVDS PX4 Device Driver
app4_reg_type = local_machine
app4_reg_name = Current Version
app4_reg_value = 1.10.01.0223
app4_reg_compare = eq
[Install_LabWindows_CVI]
app5_name = NI LabWindows/CVI Runtime (v. 17)
app5_setup_file = ..\Data\software\NI_LabWindows_CVI_Runtime_v17\setup.exe
app5_setup_argument = /qb /r:n /AcceptLicenses yes
app5_reg_display_name = NI LabWindows/CVI SxS Runtime 2017
app5_reg_type = local_machine
app5_reg_value = 17
app5_reg_name = DisplayVersion
app5_reg_compare = gte
app5_setup_reboot_computer = yes
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used for enabling windows features
; Only one thing needs to be defined for this section.
; - a text file that lists windows feature name line by line
;
; Possible keys:
; feature_list_file
;
; example:
; windows_feature_list_file = .\feature_list.txt
; ******************************************************************************************************************************
[Windows_Features]
windows_feature_list_file = .\Repository\windows_feature_list.txt
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to run various applications or scripts
;
; Possible keys:
; app#_description (OPTIONAL. Describe the purpose of running this application)
; app#_path (REQUIRED. Full path and name of the application to be run)
; - the path can take advantage of using macros. Look below for the available macros
; app#_is_console (REQUIRED. Specify if the application is a console application (i.e. DOS application)
; - value is either true/false
; app#_argument (OPTIONAL. Arguments to be passed to the application)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; - sometimes, the argument maybe include equal sign in them, but we can't have equal sign
; in the value of the INI. To make it possible, if an equal sign is needed in the ini file
; use <eq> in place of =
;
; app#_argument_path# - for each of these keys, there must be a corresponding {app#_argument_path#} defined in the value of app#_argument
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; Example 1:
; app1_path = C:\ReleaseIB_Production\app.exe
; app1_arguments = -role Datasrv -suite LSPS3 -production
;
; Example 2:
; app1_description = Extracting ActivePerl archive
; app1_path = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
;
; Example 3:
; app1_description = Extracting ActivePerl archive
; app1_path = {cd_drive}\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
; ******************************************************************************************************************************
[Enable_Network_Sharing]
app3_description = Enabling Network Discovery
app3_path = c:\windows\system32\netsh.exe
app3_is_console = true
app3_argument = advfirewall firewall set rule group<eq>"Network Discovery" new enable<eq>Yes
app4_description = Enabling File and Printer Sharing
app4_path = c:\windows\system32\netsh.exe
app4_is_console = true
app4_argument = advfirewall firewall set rule group<eq>"File and Printer Sharing" new enable<eq>Yes
[Extract_Software_Archives]
app1_description = Extracting Visual Studio 2012 archive
app1_cd_label = GUTS Support Appz 1/2
app1_path = {cd_drive}\DISK1\7-Zip\7z.exe
app1_is_console = true
app1_argument = x "{cd_drive}\DISK1\msvs2012.7z" -o"{user_temp_folder}\vs2012" -y
app2_description = Extracting Visual Studio 2012 Update 4 archive
app2_cd_label = GUTS Support Appz 1/2
app2_path = {cd_drive}\DISK1\7-Zip\7z.exe
app2_is_console = true
app2_argument = x "{cd_drive}\DISK1\msvs2012_update4.7z" -o"{user_temp_folder}\vs2012_update4" -y
app3_description = Extracting TeledyneDalsa archive
app3_cd_label = GUTS Support Appz 1/2
app3_path = {cd_drive}\DISK1\7-Zip\7z.exe
app3_is_console = true
app3_argument = x "{cd_drive}\DISK1\TeledyneDalsa.7z" -o"{user_temp_folder}\TeledyneDalsa" -y
app4_description = Extracting NI LabWindows/CVI Runtime 2017 archive
app4_cd_label = GUTS Support Appz 2/2
app4_path = {cd_drive}\DISK2\7-Zip\7z.exe
app4_is_console = true
app4_argument = x "{cd_drive}\DISK2\NI_LabWindows_CVI_Runtime_2017.7z" -o"{user_temp_folder}\NI_LabWindows_CVI_Runtime_2017" -y
[Import_Trusted_Publisher_Certificates]
app3_description = Importing trusted publisher certificate for Teledyne DALSA
app3_path = c:\windows\system32\certutil.exe
app3_is_console = true
app3_argument_path1 = ..\Data\software\TeledyneDalsa_FrameGrabber
app3_argument = -addstore "TrustedPublisher" "{app3_argument_path1}\teledyne_dalsa_trusted_publisher.cer"
;
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Modify Network Adapter's settings
;
; Possible keys:
; nic#_pci_location ( REQUIRED.)
; - the value must be in the form of: #,#,# ( bus, device, function)
; i.e.: 0,25,0 - bus = 0, device = 25, function = 0
; nic#_adapter_name (OPTIONAL. Set the name of the network adapter)
; nic#_ip_and_subnet (OPTIONAL. Set ip address and subnet mask of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,255.255.255.0
; nic#_default_gateway# (OPTIONAL. Default gateway of the network adapter)
; - the value must be in the form of: #.#.#.#
; i.e.: 192.168.0.1
; nic#_dns_servers (OPTIONAL. Set DNS servers of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,192.168.0.11
; nic#_link_speed (OPTIONAL. Set the link speed of the network adapter)
; - Before using this option. Make sure that the network adapter supports link speed setting
; This is really a registry change for the network adapter. The registry name is *SpeedDuplex
; The value for *SpeedDuplex is usually a digit ranging from 0-5.
; Here's an example:
; 0 - Auto Negotiate
; 1 - 10Mbps Half Duplex
; 2 - 10Mbps Full Duplex
; 3 - 100Mpbs Half Duplex
; 4 - 100Mbps Full Duplex
; 6 - 1Gpbs Full Duplex
; There's no 5 defined because there's no 1Gpbs Half Duplex
; IMPORTANT: The above example was taken from a Intel network card. These numbers could
; mean something else different from one network card to the next. Refer to the network
; adapter's manufacturer manual for the actual numbers and their meanings.
;
; nic#_enable_dhcp (OPTIONAL. Set network adapter to use DHCP)
; - the value must be either: true/false
; - if this is set to true, all the other settings above, except link speed, will be ignored
; this will effectively set IP and DNS Servers to be obtained automatically
;
; Example 1:
; nic1_pci_location = 0,25, 0
; nic1_link_speed = 2
; nic1_adapter_name = My Connection
; nic1_enable_dhcp = false
; nic1_ip_and_subnet = 192.168.0.10 , 255.255.255.0
; nic1_default_gateway = 192.168.0.1
; nic1_dns_servers = 192.168.0.5, 192.168.0.6
;
; ******************************************************************************************************************************
[Network_Interface_Cards]
nic1_pci_location = 17,0,0
nic1_adapter_name = Private_top
nic1_ip_and_subnet = 192.168.1.3 , 255.255.255.0
nic2_pci_location = 17,0,1
nic2_adapter_name = Public_bottom
nic2_enable_dhcp = true
nic3_pci_location = 5,0,0
nic3_adapter_name = UUT_NodeA_side_port1
nic3_ip_and_subnet = 192.168.10.201 , 255.255.255.0
nic3_link_speed = 3
nic4_pci_location = 9,0,0
nic4_adapter_name = UUT_NodeB_side_port2
nic4_ip_and_subnet = 192.168.10.200 , 255.255.255.0
nic4_link_speed = 3
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to remove/delete various files or folders
;
; Possible keys:
; item (REQUIRED. This is either a file or folder to be removed)
;
; If the item is a folder, user has the option to specify whether or not to delete the folder recursively. To specify to delete
; a folder recursively, add the word "recursive" right after the path separated by a comma
;
; The path can also include user desktop path or temporary folder
; for desktop path, use macro: {user_desktop}
; for temporary folder, use macro: {user_temp_folder}
;
; Example 1 - Delete a file:
; item = A:\test\test.hpp
;
; Example 2 - Delete a folder recursively:
; item = A:\test\test2,recursive
;
; Example 3 - Delete only the files contained in the folder:
; item = A:\test\test2
;
; Example 4 - Delete a folder on the user's desktop:
; item = {user_desktop}\test2
;
; Example 5 - Delete a folder in the user's temporary folder
; item = {user_temp_folder}\test2
; ******************************************************************************************************************************
[Files_Folders_Removal]
item = {user_temp_folder}\vs2012,recursive
item = {user_temp_folder}\vs2012_update4,recursive
item = {user_temp_folder}\TeledyneDalsa,recursive
item = {user_temp_folder}\NI_LabWindows_CVI_Runtime_2017,recursive
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to copy various packages of files from a source location to destination location
; Each XML file contains at least 1 package of files. Each file has a source and destination locations
; Key name can be anything
; Value must a be a path to a XML file
;
; example 1:
; file_package = package1.xml
; ******************************************************************************************************************************
[Files_Transfer_Packages]
file_package = ..\Data\software\Dev_PC_Software_Package.xml
file_package = ..\Data\support_files\Dev_PC_Support_Package.xml
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Specify all the paths to be created
; Possible keys:
; path (REQUIRED. Valid path to be created)
;
; example:
; path = C:\DataIIB\data\Block_IB\CV
; path = C:\DataIIB\data\Block_IB\General\Logs
; ******************************************************************************************************************************
[Paths_Creation]
path = D:\ReleaseIB_Production
path = D:\ReleaseIB_Engineering
path = D:\Data
path = D:\Data\RealTimeTM_data
path = D:\Development
path = D:\ReleaseIB_Production\REAL_TIME_TM
path = D:\ReleaseIB_Production\CorecoFrameGrabber\Video_Captures
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; To share a folder, must provide path to a folder.
; Share names are optional as the folder name will be used as the default share name.
; Any share name defined here will be used as additional share name for its corresponding folder
; The # in "path#" must match in both keys. A folder can have more than one share name.
; Possible keys:
; path# (OPTIONAL. A valid path to be shared)
; path#_additional_share_names (OPTIONAL. Additional share names associated with a path)
; - Define one or more shares names separated by comma
; path#_allowed_accounts ( Windows Built-In, local or domain accounts to be added to the permission list for this share with Full Control )
; - if this is not defined, this network share will be accessible to everyone with Full Control
; - if defined, the value must be in the following format:
; User1,User2,User3 (if more than one account is defined, separate by comma)
; The account name must either be a built-in window account or local/domain account
; if the account name is a built-in window account, it can only be one of the following:
; - everyone, authenticated users
; if the account name is a local/domain account it must be in this format: DOMAIN\UserAccountName
;
; example:
; path1 = C:\DataIIB\
; path1_additional_share_names = DataIIB1, DataIIB2
; path1_allowed_accounts = Authenticated Users,US\1117637
; path2 = C:\DataIA
; path2__additional_share_names = DataIA_1
; path2_allowed_accounts = MYCOMPUTERNAME\Duc
; path3 = C:\DataIC
; ******************************************************************************************************************************
[Paths_Sharing]
path1 = D:\ReleaseIB_Production\
path1_allowed_accounts = Authenticated Users
path2 = D:\ReleaseIB_Engineering\
path2_allowed_accounts = Authenticated Users
path3 = D:\Data\
path3_allowed_accounts = Authenticated Users
path4 = D:\Development\
path4_allowed_accounts = Authenticated Users
path5 = D:\ReleaseIB_Production\REAL_TIME_TM
path5_allowed_accounts = Authenticated Users
path6 = C:\
path6_allowed_accounts = Authenticated Users
path7 = D:\
path7_allowed_accounts = Authenticated Users
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create windows system environment variables
; the key would be the system environment variable name.
;
; Note:
; Any key defined here will have its valued replaced, except for "path" because path is a window's system environment variable
; If a key's name is path, the value specified will be appendeding to existing value
;
; path can have one or more values separated by commas
; Example:
; path = C:\folder1
; path = C:\folder1, C:\folder2
; ******************************************************************************************************************************
[Env_Variables]
;SM3_SEEKER = C:\Development\GUTS\SM3
; the address of the computer where all the data of each test is saved before being pushed to the network
;SM3_SKR_SERVER = localhost
; the address of the computer where all test data are pushed to after testing
;SM3_SKR_NETWORK = localhost
;path = C:\Perl\bin\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Add/Modify or Delete registry's key
;
; Possible keys:
; reg#_action ( REQUIRED. What action to perform)
; - there are only 2 actions ( add/modify, delete)
; reg#_path (REQUIRED. Registry folder path, not including valuename)
; reg#_type (REQUIRED)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; reg#_name_value_pair# (Optional. Registry name values and their names)
; - the registry key defined by registry path can have multiple value names and their associated values
; - Format of the value: [name:***,value:***,type:***] - replace *** with actual text
; - name can be anything
; - value is either numeric or alphanumeric depending on type
; - type can only be 1 of 4: string, multi-string, dword, qword
; If type is dword or qword then value can only be numeric
; If type is multi-string, then format of the value must be:
; [name:***,:value:***:value:***...,type:multi-string]
;
; Example 1:
; reg1_action = add/modify
; reg1_path = SOFTWARE\MySoftware\
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version,value:3,type:string]
; reg1_name_value_pair2 = [name:Version2,:value:3:value:34,type:multi-string]
;
; Example 2:
; reg1_action = add/modify
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
;
; Example3:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version]
;
; Example4:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; ******************************************************************************************************************************
[Windows_Registry]
reg1_action = add/modify
reg1_path = SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0
reg1_type = local_machine
reg1_name_value_pair1 = [name:BackConnectionHostNames,:value:ste_gu_dev_local,type:multi_string]
reg2_action = add/modify
reg2_path = SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters
reg2_type = local_machine
reg2_name_value_pair1 = [name:DisableStrictNameChecking,value:1,type:dword]
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create shortcuts on the user's desktop
;
; example:
; shortcut1_name = Data Server
; shortcut1_target_path = C:\ReleaseIB_Production\app.exe
; shortcut1_arguments = -role datasrv -suite lsps3 -production
; ******************************************************************************************************************************
[Windows_Shortcuts]
shortcut1_name = CorecoFrameGrabber
shortcut1_target_path = D:\ReleaseIB_Production\CorecoFrameGrabber\CorecoFrameGrabber.exe
shortcut1_for_all_users = true
shortcut2_name = RealTime TM
shortcut2_target_path = D:\ReleaseIB_Production\REAL_TIME_TM\RealTimeTm.exe
shortcut2_for_all_users = true
shortcut3_name = ASP Diagnostics GUI
shortcut3_target_path = D:\ReleaseIB_Production\ASP Diagnostics GUI\diag_64.exe
shortcut3_for_all_users = true

View File

@@ -0,0 +1,636 @@
; ************************************************* SM3 CONFIGURATION FILE *****************************************************
; Description:
; This is an INI file which contains the configuration information for the automated setup of either an
; ENGINEERING or PRODUCTION environment for developing or running SM3 GUTS (Guidance Unit Test Software)
;
; Author: Duc Le
;
; ******************************************************************************************************************************
;
;
;
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
[General]
Program_Name = SM3 Block IB - Engineering Setup
; 64-bit or 32-bit. Possible values: 32 or 64
Application_Platform = 32
[Global_Settings]
Always_Run_Application_Using_Admin_Account = true
Suppress_All_Prompts = true
Provide_Windows_Password_For_Auto_Login = false
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
; This section defines all the setup steps to be performed and allow the user the option of enabling/disabling each step
; The key can be anything.
; The value must define the setup step and its associated section name separated by comma: Setup_Step,Section_Name
; Below is a list of all possible setup steps:
; CONFIGURE_NETWORK_ADAPTERS
; RUN_APPLICATIONS
; INSTALL_SOFTWARE_PACKAGES
; ENABLE_INTERNET_INFORMATION_SERVICES
; CREATE_DIRECTORIES
; CREATE_NETWORK_SHARES
; SET_ENVIRONMENT_VARIABLES
; SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS
; TRANSFER_FILE_PACKAGES
; MODIFY_WINDOWS_REGISTRY
; PROCESS_GUTS_CONFIG_FILE
; CREATE_WINDOWS_SHORTCUTS
; ASSIST_BUILDING_GUTS_APP
; REMOVE_FILES_FOLDERS
;
; The setup setup can be run more than once by creating another key and assigned the setup step to it
; Each setup step needs a section name. Section name provides all the information necessary for the setup step
; The sequence of the execution of the setup steps will be in the same order as they are specified.
; ******************************************************************************************************************************
[Setup_Step_Manager]
;step = RUN_APPLICATIONS,Extract_Software_Archives
step = INSTALL_SOFTWARE_PACKAGES,Install_Software
step = CREATE_DIRECTORIES,Paths_Creation
step = CREATE_NETWORK_SHARES,Paths_Sharing
step = SET_ENVIRONMENT_VARIABLES,Env_Variables
step = TRANSFER_FILE_PACKAGES,Files_Transfer_Packages
step = CREATE_WINDOWS_SHORTCUTS,Windows_Shortcuts
;step = RUN_APPLICATIONS,Shut_Down_National_Instruments_Processes
;step = REMOVE_FILES_FOLDERS , Files_Folders_Removal
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to install various software application
; For each software application to be installed, 4 things can be defined:
;
; Possible keys:
; app#_name (REQUIRED. Name of the application to be installed/checked)
; app#_setup_file (OPTIONAL. Path and name of the installer)
; - the setup file can make use of macros. Look below for the available macros
; app#_setup_argument (OPTIONAL. Argument for the setup file. Usually to perform unattended install)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; app#_setup_confirm_prompt (OPTIONAL. Prompt user to confirm before installation starts.)
; - possible values: yes, no
; - yes: there will be prompt asking user confirm/refuse install
; - no: installation will start automatically ( this is the default )
; app#_exe_file (REQUIRED only if app#_hklm_reg_key is not specified.
; This is used to verify that the software successfully installed)
; app#_reg_path (REQUIRED only if app#_exe_file is not specified. Registry folder path, not including valuename)
; app#_reg_type (REQUIRED only if app#_reg_key is specified)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; app#_reg_value (REQUIRED only if app#_reg_key is specified. Registry value name's value)
; app#_reg_name (REQUIRED only if app#_reg_key is specified. Registry value name)
; app#_reg_compare (REQUIRED only if app#_reg_key is specified. Compare operator between value name's value specified here versus actual value read from registry)
; - there are only six options for this key ( eq, lt, gt, lte, gte, ne )
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; example 1:
; app1_name = Perl 5.6.1.638
; app1_setup_file = {user_temp_folder}\Installer.bat
; app1_exe_file = C:\Perl\bin\perl.exe
;
; example 2:
; app1_reg_path = SOFTWARE\National Instruments\NI-488.2\CurrentVersion
; app1_reg_type = local_machine
; app1_reg_value = 15.0
; app1_reg_name = Version
; app1_reg_compare = gte
; app1_name = National Instrument 488.2 (v15 or higher)
; app1_setup_file = C:\ni\setup.exe
;
; example 3:
; app1_exe_file = C:\Perl\bin\perl.exe
; app1_name = Perl 5.6.1.638
;
; example 4:
; app1_name = Sapera LT 8.11 (x64)
; app1_setup_file = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\Software\TeledyneDalsa\Sapera_LT_8.11_RuntimeSetup.exe
; app1_setup_argument = -s -f1"{app1_setup_file}\sapera_setup.iss"
; app1_reg_path = SOFTWARE\Teledyne DALSA\Sapera LT
; app1_reg_type = local_machine
; app1_reg_name = IsSaperaFrameGrabberSupport
;
; ******************************************************************************************************************************
; Visual Studio ClassRoot Registry Keys
;
; {"VS2005", "VisualStudio.DTE.8.0"},
; {"VS2008", "VisualStudio.DTE.9.0"},
; {"VS2010", "VisualStudio.DTE.10.0"},
; {"VS2012", "VisualStudio.DTE.11.0"},
; {"VS2013", "VisualStudio.DTE.12.0"},
; {"VS2015", "VisualStudio.DTE.13.0"}
;
; Visual Studio Redistributable Local_Machine Registry Keys
;
; {"VS2005_x64", @"SOFTWARE\Classes\Installer\Products\1af2a8da7e60d0b429d7e6453b3d0182"},
; {"VS2005_x86", @"SOFTWARE\Classes\Installer\Products\c1c4f01781cc94c4c8fb1542c0981a2a"},
; {"VS2008_x64", @"SOFTWARE\Classes\Installer\Products\67D6ECF5CD5FBA732B8B22BAC8DE1B4D"},
; {"VS2008_x86", @"SOFTWARE\Classes\Installer\Products\6E815EB96CCE9A53884E7857C57002F0"},
; {"VS2010_x64", @"SOFTWARE\Classes\Installer\Products\1926E8D15D0BCE53481466615F760A7F"},
; {"VS2010_x86", @"SOFTWARE\Classes\Installer\Products\1D5E3C0FEDA1E123187686FED06E995A"},
; {"VS2012_x64", @"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}"},
; {"VS2012_x86", @"SOFTWARE\Classes\Installer\Dependencies\{33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}"},
; {"VS2013_x64", @"SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f}"},
; {"VS2013_x86", @"SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}"},
; {"VS2015_x64", @"SOFTWARE\Classes\Installer\Dependencies\{3ee5e5bb-b7cc-4556-8861-a00a82977d6c}"},
; {"VS2015_x86", @"SOFTWARE\Classes\Installer\Dependencies\{23daf363-3020-4059-b3ae-dc4ad39fed19}"}
;
; ******************************************************************************************************************************
[Install_Software]
app5_name = Visual Studio 2012
app5_setup_argument = /passive /norestart
app5_reg_path = VisualStudio.DTE.11.0
app5_reg_type = classes_root
app5_setup_file = ..\Data\software\Visual_Studio_2012\vs_professional.exe
app6_name = Visual Studio 2012 - Update 4
app6_setup_file = ..\Data\software\Visual_Studio_2012_Update_4\VS2012.4.exe
app6_setup_argument = /passive /norestart
app6_reg_path = SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\11.0\CompilerCore\1033
app6_reg_type = local_machine
app6_reg_value = 11.0.61030
app6_reg_name = UpdateVersion
app6_reg_compare = eq
app2_name = National Instrument 488.2 (ver. 17)
app2_setup_file = ..\Data\software\NI_4882_v17\setup.exe
app2_setup_argument = /qb /r:n /AcceptLicenses yes
app2_reg_display_name = NI-488.2 17.0
app2_reg_type = local_machine
app2_reg_value = 17
app2_reg_name = DisplayVersion
app2_reg_compare = gte
app2_reboot_computer_at_completion = yes
app2_exit_codes_to_ignore = 3010
app3_name = National Instrument VXI (ver. 16)
app3_setup_file = ..\Data\software\NI_VXI_v17\setup.exe
app3_setup_argument = /qb /r:n /AcceptLicenses yes
app3_reg_display_name = NI-VXI 16.0
app3_reg_type = local_machine
app3_reg_value = 16
app3_reg_name = DisplayVersion
app3_reg_compare = gte
app3_reboot_computer_at_completion = yes
app3_exit_codes_to_ignore = 3010
app7_name = Sapera LT 8.11 (x64)
app7_setup_argument = -s -f1"{app7_setup_file}\sapera_setup.iss"
app7_setup_file = ..\Data\software\TeledyneDalsa_FrameGrabber\Sapera_LT_8.11_RuntimeSetup.exe
app7_reg_display_name = Teledyne DALSA Sapera LT Runtime 8.11.00.1621 (Frame grabbers and CameraLink cameras)
app7_reg_type = local_machine
app7_reg_value = 8.11
app7_reg_name = DisplayVersion
app7_reg_compare = gte
app7_reboot_computer_at_completion = yes
;app1_setup_confirm_prompt = yes
app1_name = ActivePerl 5.6.1.638
app1_setup_file = ..\Data\software\Perl_5_6\Installer_Silent.bat
app1_exe_file = C:\Perl\bin\perl.exe
app4_name = Visual Studio Redistributable 2013 (x86)
app4_setup_file = ..\Data\software\VS2013_Redistributable\vcredist_x86.EXE
app4_setup_argument = /install /passive /norestart
app4_reg_path = SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1}
app4_reg_type = local_machine
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used for enabling windows features
; Only one thing needs to be defined for this section.
; - a text file that lists windows feature name line by line
;
; Possible keys:
; feature_list_file
;
; example:
; windows_feature_list_file = .\feature_list.txt
; ******************************************************************************************************************************
[Windows_Features]
windows_feature_list_file = ..\Data\windows_feature_list.txt
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to run various applications or scripts
;
; Possible keys:
; app#_description (OPTIONAL. Describe the purpose of running this application)
; app#_path (REQUIRED. Full path and name of the application to be run)
; - the path can take advantage of using macros. Look below for the available macros
; app#_is_console (REQUIRED. Specify if the application is a console application (i.e. DOS application)
; - value is either true/false
; app#_argument (OPTIONAL. Arguments to be passed to the application)
; - sometimes the argument can include paths. Some programs will require absolute path while others allow relative paths
; the user has the option of specifying relative paths in the argument and have the program resolve them at runtime
; In order to make this possible, the user will have to specify a new key for each path to be resolved in the argument
; - the argument can specify {app#_path}
; - the argument can make use of macros. Look below for the available macros
; - the actual path being inserted in the argument will not have backslash at the end of the path
; - sometimes, the argument maybe include equal sign in them, but we can't have equal sign
; in the value of the INI. To make it possible, if an equal sign is needed in the ini file
; use <eq> in place of =
;
; app#_argument_path# - for each of these keys, there must be a corresponding {app#_argument_path#} defined in the value of app#_argument
;
; Available Path macros:
; {user_desktop}, {user_temp_folder}, {cd_drive}
;
; Example 1:
; app1_path = C:\ReleaseIB_Production\app.exe
; app1_arguments = -role Datasrv -suite LSPS3 -production
;
; Example 2:
; app1_description = Extracting ActivePerl archive
; app1_path = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
;
; Example 3:
; app1_description = Extracting ActivePerl archive
; app1_path = {cd_drive}\7-Zip\7z.exe
; app1_argument_path1 = ..\..\..\..\..\Deployment\SM3_IB_Auto_Setup\Repository\software\
; app1_argument = x "{app1_argument_path1}\Perl.7z" -o"{user_temp_folder}" -y
; ******************************************************************************************************************************
[Extract_Software_Archives]
;app1_description = Extracting Visual Studio 2012 archive
;app1_cd_label = GUTS Support Appz 1/2
;app1_path = {cd_drive}\DISK1\7-Zip\7z.exe
;app1_is_console = true
;app1_argument = x "{cd_drive}\DISK1\msvs2012.7z" -o"{user_temp_folder}\vs2012" -y
;app2_description = Extracting Visual Studio 2012 Update 4 archive
;app2_cd_label = GUTS Support Appz 1/2
;app2_path = {cd_drive}\DISK1\7-Zip\7z.exe
;app2_is_console = true
;app2_argument = x "{cd_drive}\DISK1\msvs2012_update4.7z" -o"{user_temp_folder}\vs2012_update4" -y
app3_description = Extracting NI 488.2 v17 archive
app3_cd_label = GUTS Support Appz 1/2
app3_path = E:\Duc\IB_Appz\DISK1\7-Zip\7z.exe
app3_is_console = true
app3_argument = x "E:\Duc\IB_Appz\DISK1\NI_4882_v17.7z" -o"{user_temp_folder}" -y
app4_description = Extracting NI VXI v16 archive
app4_cd_label = GUTS Support Appz 1/2
app4_path = E:\Duc\IB_Appz\DISK1\7-Zip\7z.exe
app4_is_console = true
app4_argument = x "E:\Duc\IB_Appz\DISK1\NI_VXI_v17.7z" -o"{user_temp_folder}" -y
app5_description = Extracting ActivePerl 5.6 archive
app5_cd_label = GUTS Support Appz 1/2
app5_path = E:\Duc\IB_Appz\DISK1\7-Zip\7z.exe
app5_is_console = true
app5_argument = x "E:\Duc\IB_Appz\DISK1\Perl_5_6.7z" -o"{user_temp_folder}" -y
app6_description = Extracting Teledyne Dalsa SaperaLT Runtime 8.11 archive
app6_cd_label = GUTS Support Appz 1/2
app6_path = E:\Duc\IB_Appz\DISK1\7-Zip\7z.exe
app6_is_console = true
app6_argument = x "E:\Duc\IB_Appz\DISK1\SaperaLT_Runtime_8_11.7z" -o"{user_temp_folder}" -y
[Shut_Down_National_Instruments_Processes]
app1_description = Killing process nierserver.exe
app1_path = C:\Windows\system32\taskkill.exe
app1_is_console = true
app1_argument = /f /im nierserver.exe
;
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Modify Network Adapter's settings
;
; Possible keys:
; nic#_pci_location ( REQUIRED.)
; - the value must be in the form of: #,#,# ( bus, device, function)
; i.e.: 0,25,0 - bus = 0, device = 25, function = 0
; nic#_adapter_name (OPTIONAL. Set the name of the network adapter)
; nic#_ip_and_subnet (OPTIONAL. Set ip address and subnet mask of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,255.255.255.0
; nic#_default_gateway# (OPTIONAL. Default gateway of the network adapter)
; - the value must be in the form of: #.#.#.#
; i.e.: 192.168.0.1
; nic#_dns_servers (OPTIONAL. Set DNS servers of network adapter)
; - the value must be in the form of: #.#.#.#,#.#.#.#
; i.e.: 192.168.0.10,192.168.0.11
; nic#_link_speed (OPTIONAL. Set the link speed of the network adapter)
; - Before using this option. Make sure that the network adapter supports link speed setting
; This is really a registry change for the network adapter. The registry name is *SpeedDuplex
; The value for *SpeedDuplex is usually a digit ranging from 0-5.
; Here's an example:
; 0 - Auto Negotiate
; 1 - 10Mbps Half Duplex
; 2 - 10Mbps Full Duplex
; 3 - 100Mpbs Half Duplex
; 4 - 100Mbps Full Duplex
; 6 - 1Gpbs Full Duplex
; There's no 5 defined because there's no 1Gpbs Half Duplex
; IMPORTANT: The above example was taken from a Intel network card. These numbers could
; mean something else different from one network card to the next. Refer to the network
; adapter's manufacturer manual for the actual numbers and their meanings.
;
; nic#_enable_dhcp (OPTIONAL. Set network adapter to use DHCP)
; - the value must be either: true/false
; - if this is set to true, all the other settings above, except link speed, will be ignored
; this will effectively set IP and DNS Servers to be obtained automatically
;
; Example 1:
; nic1_pci_location = 0,25, 0
; nic1_link_speed = 2
; nic1_adapter_name = My Connection
; nic1_enable_dhcp = false
; nic1_ip_and_subnet = 192.168.0.10 , 255.255.255.0
; nic1_default_gateway = 192.168.0.1
; nic1_dns_servers = 192.168.0.5, 192.168.0.6
;
; ******************************************************************************************************************************
[Network_Interface_Cards]
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to remove/delete various files or folders
;
; Possible keys:
; item (REQUIRED. This is either a file or folder to be removed)
;
; If the item is a folder, user has the option to specify whether or not to delete the folder recursively. To specify to delete
; a folder recursively, add the word "recursive" right after the path separated by a comma
;
; The path can also include user desktop path or temporary folder
; for desktop path, use macro: {user_desktop}
; for temporary folder, use macro: {user_temp_folder}
;
; Example 1 - Delete a file:
; item = A:\test\test.hpp
;
; Example 2 - Delete a folder recursively:
; item = A:\test\test2,recursive
;
; Example 3 - Delete only the files contained in the folder:
; item = A:\test\test2
;
; Example 4 - Delete a folder on the user's desktop:
; item = {user_desktop}\test2
;
; Example 5 - Delete a folder in the user's temporary folder
; item = {user_temp_folder}\test2
; ******************************************************************************************************************************
[Files_Folders_Removal]
item = {user_temp_folder}\Perl_5_6,recursive
item = {user_temp_folder}\vs2012,recursive
item = {user_temp_folder}\vs2012_update4,recursive
item = {user_temp_folder}\NI_4882_v17,recursive
item = {user_temp_folder}\NI_VXI_v17,recursive
item = {user_temp_folder}\SaperaLT_Runtime_8_11,recursive
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is used to copy various packages of files from a source location to destination location
; Each XML file contains at least 1 package of files. Each file has a source and destination locations
; Key name can be anything
; Value must a be a path to a XML file
;
; example 1:
; file_package = package1.xml
; ******************************************************************************************************************************
[Files_Transfer_Packages]
file_package = ..\Data\software\Engineering_PC_Software_Package.xml
file_package = ..\Data\support_files\Engineering_PC_Support_Package.xml
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Specify all the paths to be created
; Possible keys:
; path (REQUIRED. Valid path to be created)
;
; example:
; path1 = C:\DataIIB\data\Block_IB\CV
; path2 = C:\DataIIB\data\Block_IB\General\Logs
; ******************************************************************************************************************************
[Paths_Creation]
path = C:\ReleaseIB_Engineering\
path = C:\ReleaseIB_Production\
path = C:\DataIB\data\Block_IB\CV
path = C:\DataIB\data\Block_IB\General\Logs
path = C:\DataIB\data\Block_IB\General\Scripts
path = C:\DataIB\data\Block_IB\General\Temp\SingleStepScript
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; To share a folder, must provide path to a folder.
; Share names are optional as the folder name will be used as the default share name.
; Any share name defined here will be used as additional share name for its corresponding folder
; The # in "path#" must match in both keys. A folder can have more than one share name.
; Possible keys:
; path# (OPTIONAL. A valid path to be shared)
; path#_additional_share_names (OPTIONAL. Additional share names associated with a path)
; - Define one or more shares names separated by comma
; path#_allowed_accounts ( Windows Built-In, local or domain accounts to be added to the permission list for this share with Full Control )
; - if this is not defined, this network share will be accessible to everyone with Full Control
; - if defined, the value must be in the following format:
; User1,User2,User3 (if more than one account is defined, separate by comma)
; The account name must either be a built-in window account or local/domain account
; if the account name is a built-in window account, it can only be one of the following:
; - everyone, authenticated users
; if the account name is a local/domain account it must be in this format: DOMAIN\UserAccountName
;
; example:
; path1 = C:\DataIIB\
; path1_additional_share_names = DataIIB1, DataIIB2
; path1_allowed_accounts = Authenticated Users,US\1117637
; path2 = C:\DataIA
; path2__additional_share_names = DataIA_1
; path2_allowed_accounts = MYCOMPUTERNAME\Duc
; path3 = C:\DataIC
; ******************************************************************************************************************************
[Paths_Sharing]
path1 = C:\ReleaseIB_Engineering\
path2_additional_share_names = Data
path2 = C:\DataIB\
path3_additional_share_names = Release
path3 = C:\ReleaseIB_Production\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create windows system environment variables
; the key would be the system environment variable name.
;
; Note:
; Any key defined here will have its valued replaced, except for "path" because path is a window's system environment variable
; If a key's name is path, the value specified will be appendeding to existing value
;
; path can have one or more values separated by commas
; Example:
; path = C:\folder1
; path = C:\folder1, C:\folder2
; ******************************************************************************************************************************
[Env_Variables]
SM3_SEEKER = C:\Development\GUTS\SM3
; the address of the computer where all the data of each test is saved before being pushed to the network
SM3_SKR_SERVER = localhost
; the address of the computer where all test data are pushed to after testing
SM3_SKR_NETWORK = localhost
path = C:\Perl\bin\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Add/Modify or Delete registry's key
;
; Possible keys:
; reg#_action ( REQUIRED. What action to perform)
; - there are only 2 actions ( add/modify, delete)
; reg#_path (REQUIRED. Registry folder path, not including valuename)
; reg#_type (REQUIRED)
; - there are only three options for this key ( classes_root, current_user, local_machine)
; reg#_name_value_pair# (Optional. Registry name values and their names)
; - the registry key defined by registry path can have multiple value names and their associated values
; - Format of the value: [name:***,value:***,type:***] - replace *** with actual text
; - name can be anything
; - value is either numeric or alphanumeric depending on type
; - type can only be 1 of 4: string, multi_string, dword, qword
; If type is dword or qword then value can only be numeric
; If type is multi-string, then format of the value must be:
; [name:***,:value:***:value:***...,type:multi_string]
;
; Example 1:
; reg1_action = add/modify
; reg1_path = SOFTWARE\MySoftware\
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version,value:3,type:string]
; reg1_name_value_pair2 = [name:Version2,:value:3:value:34,type:multi-string]
;
; Example 2:
; reg1_action = add/modify
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
;
; Example3:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; reg1_name_value_pair1 = [name:Version]
;
; Example4:
; reg1_action = delete
; reg1_path = SOFTWARE\Duc\Sup
; reg1_type = local_machine
; ******************************************************************************************************************************
[Windows_Registry]
;reg1_action = delete
;reg1_path = SOFTWARE\Duc\
;reg1_type = local_machine
;reg1_name_value_pairs = Versionn[:]3[,]ginrl[:]boy
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Create shortcuts on the user's desktop
;
; example:
; shortcut1_name = Data Server
; shortcut1_target_path = C:\ReleaseIB_Production\app.exe
; shortcut1_arguments = -role datasrv -suite lsps3 -production
; ******************************************************************************************************************************
[Windows_Shortcuts]
shortcut1_name = GUTS Startup - Dev
shortcut1_target_path = C:\Perl\bin\perl.exe
shortcut1_arguments = C:\ReleaseIB_Production\Utils\guts_startup_dev.pl
shortcut2_name = CorecoFramegrabber
shortcut2_target_path = C:\ReleaseIB_Production\CorecoFrameGrabber\CorecoFrameGrabber.exe
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; Before building GUTS, the dashboard.pl must be executed to copy additional files to the GUTS project folder
; Before dashboard.pl can be run, 2 environment variables must be set:
; 1. Path to the GUTS development folder - this is where the script know to put the files in
; 2. Path to the Perl executable
; Possible keys:
; GUTS_Development_Folder - (REQUIRED. The path to where the GUTS Project is located)
; list_of_additional_files (REQUIRED. The full path and name of file that contains a complete list of files to be added by the dashboard.pl)
; perl_binary_path (REQUIRED. Path to where the perl executable is. This is necessary to run perl scripts)
;
; example:
; ******************************************************************************************************************************
[GUTS_Pre_Build_Assistance]
GUTS_Development_Folder = C:\GUTS_31202_VS2012_Synergy_PostScriptRun1\GUTS\SM3
list_of_additional_files = ..\..\..\..\GUTS\list_of_guts_additional_files.txt
perl_binary_path = C:\Perl\bin\
; ******************************************************************************************************************************
; THIS SECTION IS REQUIRED
; ******************************************************************************************************************************
; This section is mainly to configure the GUTS config file's settings and renaming to the right name for the GUTS app to use
; ******************************************************************************************************************************
[GUTS_Info]
sm3seeker_config_file = .\Repository\support_files\All\sm3seeker.cfg
; folder where GUTS app and DLLs are located and run from
Guts_Bin_Dir = C:\ReleaseIB_Production\
; ******************************************************************************************************************************
; THIS SECTION IS OPTIONAL
; ******************************************************************************************************************************
; This section is responsible for changing the values of the keys in the GUTS Config File.
; The GUTS config file name and location are determined by the various settings in section [GUTS_Info], therefore there's no need to
; specify what and where the file is located at. It should be in the GUTS Bin directory and named according to the hardware
; type that is defined in section [GUTS_Info].
;
; Key Format: Can be anything
; Value Format: the value should have a [,] as a delimiter between the Section, Key and Value in the GUTS' Config File
;
; Example:
; Setting = General[,]DATA_SRV_ADDR[,]localhost
; General - section name in the GUTS Config File
; DATA_SRV_ADDR - the key in the section in the GUTS Config File
; localhost - value associated with the key
;
; ******************************************************************************************************************************
[GUTS_Config_File]
; IP address of the GUTS Data Server
Setting = General[,]DATA_SRV_ADDR[,]localhost
; IP address of the GUTS Server
Setting = General[,]GUTS_SRV_ADDR[,]localhost
; IP address of the GUTS GUOT Server
Setting = General[,]GUTS_GUOT_SRV_ADDR[,]localhost
; IP address of the Coreco Framegrabber Server
Setting = General[,]CORECO_FRAMEGRABBER_SRV_ADDR[,]localhost
; IP address of the Acroamatics server
Setting = General[,]TM_DECOM_ADDR[,]localhost
; IP address of the wideband server
Setting = General[,]TM_DDR100_ADDR[,]localhost
; IP address of the LSPS controller server
Setting = General[,]LSPS_ADDR[,]localhost
; IP address of the vendor's guot server
Setting = UUT_CONTROLLER[,]VENDOR_GUOT_SRV_ADDR[,]localhost
Setting = OPTICS[,]WAVELENGTH[,]2.2

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
======================================================================================================================================
; FileName.xml
;=====================================================================================================================================
;
; Description or purpose:
; This XML file specifies all the directories and files that are
; to be copied/created from one source folder to one destination folder.
;
; Note/Restrictions:
; When commenting in this file, do not use 2 - adjacent to each other
; or the XML parser will hang. 2 hyphens adjacent to each other denote
; the start/end of a comment. Do not place comment at the top of the actual
; XML tags or the XML parser will hang.
;
; Usage:
; + 1st level node is the root, i.e. <?xml version="1.0" encoding="utf-8"?>
;
; + 2nd level node is the sibling of the 1st level node. Don't have more than 1 2nd-level node.
; The actual tree starts from the 2nd level node.
; In this example, 2nd-level node is <tree> ... </tree>
;
; + 3rd level node must be inside 2nd-level node. It defines a package of files to be copied <package name="" startingsourcepath="" startingdestpath="">
; ++ [name] denotes the name of the package
; ++ [startingsourcepath] is optional. This denotes the start path of all the source files to be copied. If this attribute
; is not defined. The starting root path will default to the directory where this XML file is located
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
; ++ [startingdestpath] is required. This denotes the start path of where all the source files will be copied to.
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
;
; + 4th level node must be inside 3rd level node.
; Can have either of the following tags
; 1. <filescopy sourcedir="_" destdir="_"></filescopy>
; This allows user to specify what files to be copied from 1 source folder to 1 destination folder
; ++ [sourcedir] denotes the source directory where all the source file(s) resides.
; [sourcedir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
; if [sourcedir] is not defined, then all files defined within this node are to be created anew
; ++ [destdir] denotes the destination directory relative to the root dest dir
; [destdir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
;
; 2. <folderscopy sourcedir="_" destdir="_"/></folderscopy>
; This allows user to copy anything under the source folder to a destination folder. All files, folders
; and subfolders and subfiles will be copied to the destination folder
;
; + 5th level node must be inside 4th level node.
; Can have any combination of the following tags:
; 1. <fileinclude saveas="_" actions="_,_">filename</fileinclude>
; Description: Specifies file(s) to be copied
; ++ [saveas] is optional. Denotes to save the source file with a different name at the destination
; ++ [actions] is optional. Denotes the action to be perform on the file. Multiple actions are delimited
; with comma.
; Name of each action should be the same name defined by the Enum eFileAction that is defined
; in the frmBuildSoftwarePackage.cs.
; Possible actions are: CreateSWBuildIDEntries, BuildProjectUsingVS2009Compiler, BuildProjectUsingVS2010Compiler,
; BuildProjectInDebug, BuildProjectInRelease
;
; 2. <fileexclude>filename</fileinclude>
; Description: Specifies file(s) to be ignored
; ++ [filename] can be an actual file name or a wildcard such as "*.*" and "*.ext"
;
; Example 1 - Create a new file:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy destdir="dest">
; <fileinclude>newfile.txt</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 2 - Copy all the files in the root directory to "dest" directory in the root directory:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy sourcedir="." destdir=".\dest">
; <fileinclude>*.*</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 3 - Copy all files/folders/subfolders/subfiles within c:\source to c:\dest:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <folderscopy sourcedir="c:\source" destdir="c:\dest" />
; </package>
; </tree>
;=====================================================================================================================================
;
; REVISION HISTORY
;
; Date Programmer Proj. TEMA Title
; - - - - - - - - - - - - - - - - - - - - - - - - - -
; 061112 D.Le
;=====================================================================================================================================
-->
<tree>
<package name="Control PC Software Package" startingsourcepath="." startingdestpath="D:\ReleaseIB_Production">
<folderscopy sourcedir=".\PushFilesGui" destdir=".\Utils\PushFilesGui" />
<folderscopy sourcedir=".\GUTS" destdir="." />
</package>
</tree>

View File

@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
======================================================================================================================================
; FileName.xml
;=====================================================================================================================================
;
; Description or purpose:
; This XML file specifies all the directories and files that are
; to be copied/created from one source folder to one destination folder.
;
; Note/Restrictions:
; When commenting in this file, do not use 2 - adjacent to each other
; or the XML parser will hang. 2 hyphens adjacent to each other denote
; the start/end of a comment. Do not place comment at the top of the actual
; XML tags or the XML parser will hang.
;
; Usage:
; + 1st level node is the root, i.e. <?xml version="1.0" encoding="utf-8"?>
;
; + 2nd level node is the sibling of the 1st level node. Don't have more than 1 2nd-level node.
; The actual tree starts from the 2nd level node.
; In this example, 2nd-level node is <tree> ... </tree>
;
; + 3rd level node must be inside 2nd-level node. It defines a package of files to be copied <package name="" startingsourcepath="" startingdestpath="">
; ++ [name] denotes the name of the package
; ++ [startingsourcepath] is optional. This denotes the start path of all the source files to be copied. If this attribute
; is not defined. The starting root path will default to the directory where this XML file is located
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
; ++ [startingdestpath] is required. This denotes the start path of where all the source files will be copied to.
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
;
; + 4th level node must be inside 3rd level node.
; Can have either of the following tags
; 1. <filescopy sourcedir="_" destdir="_"></filescopy>
; This allows user to specify what files to be copied from 1 source folder to 1 destination folder
; ++ [sourcedir] denotes the source directory where all the source file(s) resides.
; [sourcedir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
; if [sourcedir] is not defined, then all files defined within this node are to be created anew
; ++ [destdir] denotes the destination directory relative to the root dest dir
; [destdir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
;
; 2. <folderscopy sourcedir="_" destdir="_"/></folderscopy>
; This allows user to copy anything under the source folder to a destination folder. All files, folders
; and subfolders and subfiles will be copied to the destination folder
;
; + 5th level node must be inside 4th level node.
; Can have any combination of the following tags:
; 1. <fileinclude saveas="_" actions="_,_">filename</fileinclude>
; Description: Specifies file(s) to be copied
; ++ [saveas] is optional. Denotes to save the source file with a different name at the destination
; ++ [actions] is optional. Denotes the action to be perform on the file. Multiple actions are delimited
; with comma.
; Name of each action should be the same name defined by the Enum eFileAction that is defined
; in the frmBuildSoftwarePackage.cs.
; Possible actions are: CreateSWBuildIDEntries, BuildProjectUsingVS2009Compiler, BuildProjectUsingVS2010Compiler,
; BuildProjectInDebug, BuildProjectInRelease
;
; 2. <fileexclude>filename</fileinclude>
; Description: Specifies file(s) to be ignored
; ++ [filename] can be an actual file name or a wildcard such as "*.*" and "*.ext"
;
; Example 1 - Create a new file:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy destdir="dest">
; <fileinclude>newfile.txt</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 2 - Copy all the files in the root directory to "dest" directory in the root directory:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy sourcedir="." destdir=".\dest">
; <fileinclude>*.*</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 3 - Copy all files/folders/subfolders/subfiles within c:\source to c:\dest:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <folderscopy sourcedir="c:\source" destdir="c:\dest" />
; </package>
; </tree>
;=====================================================================================================================================
;
; REVISION HISTORY
;
; Date Programmer Proj. TEMA Title
; - - - - - - - - - - - - - - - - - - - - - - - - - -
; 061112 D.Le
;=====================================================================================================================================
-->
<tree>
<package name="Control PC Support Package 1" startingsourcepath="L:\Dle\Programs\SM3\IB\GUTS\ConfigFiles\Control_PC" startingdestpath="D:\ReleaseIB_Production">
<filescopy destdir=".">
<fileinclude>PathLossLog.txt</fileinclude>
</filescopy>
<filescopy sourcedir="." destdir=".">
<fileinclude>DaqSetup.dat</fileinclude>
</filescopy>
<filescopy sourcedir="." destdir=".">
<fileinclude>SecretTlmMsg.dll</fileinclude>
</filescopy>
<filescopy sourcedir="." destdir=".">
<fileinclude>Sm3Seeker.cfg</fileinclude>
</filescopy>
<filescopy sourcedir="." destdir=".">
<fileinclude>startup.pl</fileinclude>
</filescopy>
<filescopy sourcedir="." destdir=".">
<fileinclude>startupConfig.ini</fileinclude>
</filescopy>
<filescopy sourcedir="." destdir=".">
<fileinclude>WidebandAccount.bat</fileinclude>
</filescopy>
</package>
<package name="Control PC Support Package 2" startingsourcepath="L:\Dle\Programs\SM3\IB\GUTS\ConfigFiles\Control_PC" startingdestpath="C:\Windows\System32\drivers\etc">
<filescopy sourcedir="." destdir=".">
<fileinclude>hosts</fileinclude>
</filescopy>
</package>
</tree>

View File

@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
======================================================================================================================================
; FileName.xml
;=====================================================================================================================================
;
; Description or purpose:
; This XML file specifies all the directories and files that are
; to be copied/created from one source folder to one destination folder.
;
; Note/Restrictions:
; When commenting in this file, do not use 2 - adjacent to each other
; or the XML parser will hang. 2 hyphens adjacent to each other denote
; the start/end of a comment. Do not place comment at the top of the actual
; XML tags or the XML parser will hang.
;
; Usage:
; + 1st level node is the root, i.e. <?xml version="1.0" encoding="utf-8"?>
;
; + 2nd level node is the sibling of the 1st level node. Don't have more than 1 2nd-level node.
; The actual tree starts from the 2nd level node.
; In this example, 2nd-level node is <tree> ... </tree>
;
; + 3rd level node must be inside 2nd-level node. It defines a package of files to be copied <package name="" startingsourcepath="" startingdestpath="">
; ++ [name] denotes the name of the package
; ++ [startingsourcepath] is optional. This denotes the start path of all the source files to be copied. If this attribute
; is not defined. The starting root path will default to the directory where this XML file is located
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
; ++ [startingdestpath] is required. This denotes the start path of where all the source files will be copied to.
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
;
; + 4th level node must be inside 3rd level node.
; Can have either of the following tags
; 1. <filescopy sourcedir="_" destdir="_"></filescopy>
; This allows user to specify what files to be copied from 1 source folder to 1 destination folder
; ++ [sourcedir] denotes the source directory where all the source file(s) resides.
; [sourcedir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
; if [sourcedir] is not defined, then all files defined within this node are to be created anew
; ++ [destdir] denotes the destination directory relative to the root dest dir
; [destdir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
;
; 2. <folderscopy sourcedir="_" destdir="_"/></folderscopy>
; This allows user to copy anything under the source folder to a destination folder. All files, folders
; and subfolders and subfiles will be copied to the destination folder
;
; + 5th level node must be inside 4th level node.
; Can have any combination of the following tags:
; 1. <fileinclude saveas="_" actions="_,_">filename</fileinclude>
; Description: Specifies file(s) to be copied
; ++ [saveas] is optional. Denotes to save the source file with a different name at the destination
; ++ [actions] is optional. Denotes the action to be perform on the file. Multiple actions are delimited
; with comma.
; Name of each action should be the same name defined by the Enum eFileAction that is defined
; in the frmBuildSoftwarePackage.cs.
; Possible actions are: CreateSWBuildIDEntries, BuildProjectUsingVS2009Compiler, BuildProjectUsingVS2010Compiler,
; BuildProjectInDebug, BuildProjectInRelease
;
; 2. <fileexclude>filename</fileinclude>
; Description: Specifies file(s) to be ignored
; ++ [filename] can be an actual file name or a wildcard such as "*.*" and "*.ext"
;
; Example 1 - Create a new file:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy destdir="dest">
; <fileinclude>newfile.txt</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 2 - Copy all the files in the root directory to "dest" directory in the root directory:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy sourcedir="." destdir=".\dest">
; <fileinclude>*.*</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 3 - Copy all files/folders/subfolders/subfiles within c:\source to c:\dest:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <folderscopy sourcedir="c:\source" destdir="c:\dest" />
; </package>
; </tree>
;=====================================================================================================================================
;
; REVISION HISTORY
;
; Date Programmer Proj. TEMA Title
; - - - - - - - - - - - - - - - - - - - - - - - - - -
; 061112 D.Le
;=====================================================================================================================================
-->
<tree>
<package name="Dev PC Software Package" startingsourcepath="." startingdestpath="D:\ReleaseIB_Production">
<folderscopy sourcedir=".\CorecoFrameGrabber" destdir=".\CorecoFrameGrabber" />
<folderscopy sourcedir=".\RealTimeTm" destdir=".\REAL_TIME_TM" />
<folderscopy sourcedir=".\ASP_Diagnostic_GUI" destdir=".\ASP Diagnostics GUI" />
</package>
</tree>

View File

@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
======================================================================================================================================
; FileName.xml
;=====================================================================================================================================
;
; Description or purpose:
; This XML file specifies all the directories and files that are
; to be copied/created from one source folder to one destination folder.
;
; Note/Restrictions:
; When commenting in this file, do not use 2 - adjacent to each other
; or the XML parser will hang. 2 hyphens adjacent to each other denote
; the start/end of a comment. Do not place comment at the top of the actual
; XML tags or the XML parser will hang.
;
; Usage:
; + 1st level node is the root, i.e. <?xml version="1.0" encoding="utf-8"?>
;
; + 2nd level node is the sibling of the 1st level node. Don't have more than 1 2nd-level node.
; The actual tree starts from the 2nd level node.
; In this example, 2nd-level node is <tree> ... </tree>
;
; + 3rd level node must be inside 2nd-level node. It defines a package of files to be copied <package name="" startingsourcepath="" startingdestpath="">
; ++ [name] denotes the name of the package
; ++ [startingsourcepath] is optional. This denotes the start path of all the source files to be copied. If this attribute
; is not defined. The starting root path will default to the directory where this XML file is located
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
; ++ [startingdestpath] is required. This denotes the start path of where all the source files will be copied to.
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
;
; + 4th level node must be inside 3rd level node.
; Can have either of the following tags
; 1. <filescopy sourcedir="_" destdir="_"></filescopy>
; This allows user to specify what files to be copied from 1 source folder to 1 destination folder
; ++ [sourcedir] denotes the source directory where all the source file(s) resides.
; [sourcedir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
; if [sourcedir] is not defined, then all files defined within this node are to be created anew
; ++ [destdir] denotes the destination directory relative to the root dest dir
; [destdir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
;
; 2. <folderscopy sourcedir="_" destdir="_"/></folderscopy>
; This allows user to copy anything under the source folder to a destination folder. All files, folders
; and subfolders and subfiles will be copied to the destination folder
;
; + 5th level node must be inside 4th level node.
; Can have any combination of the following tags:
; 1. <fileinclude saveas="_" actions="_,_">filename</fileinclude>
; Description: Specifies file(s) to be copied
; ++ [saveas] is optional. Denotes to save the source file with a different name at the destination
; ++ [actions] is optional. Denotes the action to be perform on the file. Multiple actions are delimited
; with comma.
; Name of each action should be the same name defined by the Enum eFileAction that is defined
; in the frmBuildSoftwarePackage.cs.
; Possible actions are: CreateSWBuildIDEntries, BuildProjectUsingVS2009Compiler, BuildProjectUsingVS2010Compiler,
; BuildProjectInDebug, BuildProjectInRelease
;
; 2. <fileexclude>filename</fileinclude>
; Description: Specifies file(s) to be ignored
; ++ [filename] can be an actual file name or a wildcard such as "*.*" and "*.ext"
;
; Example 1 - Create a new file:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy destdir="dest">
; <fileinclude>newfile.txt</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 2 - Copy all the files in the root directory to "dest" directory in the root directory:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy sourcedir="." destdir=".\dest">
; <fileinclude>*.*</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 3 - Copy all files/folders/subfolders/subfiles within c:\source to c:\dest:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <folderscopy sourcedir="c:\source" destdir="c:\dest" />
; </package>
; </tree>
;=====================================================================================================================================
;
; REVISION HISTORY
;
; Date Programmer Proj. TEMA Title
; - - - - - - - - - - - - - - - - - - - - - - - - - -
; 061112 D.Le
;=====================================================================================================================================
-->
<tree>
<package name="Dev PC Support Package 1" startingsourcepath="L:\Dle\Programs\SM3\IB\GUTS\ConfigFiles\Dev_PC" startingdestpath="D:\ReleaseIB_Production">
<filescopy sourcedir="." destdir=".\CorecoFrameGrabber">
<fileinclude>Grabber.cfg</fileinclude>
</filescopy>
<filescopy sourcedir=".\RealTimeTM" destdir=".\REAL_TIME_TM">
<fileinclude>*.*</fileinclude>
</filescopy>
</package>
<package name="Dev PC Support Package 2" startingsourcepath="L:\Dle\Programs\SM3\IB\GUTS\ConfigFiles\Dev_PC" startingdestpath="C:\Windows\System32\drivers\etc">
<filescopy sourcedir="." destdir=".">
<fileinclude>hosts</fileinclude>
</filescopy>
</package>
</tree>

View File

@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
======================================================================================================================================
; FileName.xml
;=====================================================================================================================================
;
; Description or purpose:
; This XML file specifies all the directories and files that are
; to be copied/created from one source folder to one destination folder.
;
; Note/Restrictions:
; When commenting in this file, do not use 2 - adjacent to each other
; or the XML parser will hang. 2 hyphens adjacent to each other denote
; the start/end of a comment. Do not place comment at the top of the actual
; XML tags or the XML parser will hang.
;
; Usage:
; + 1st level node is the root, i.e. <?xml version="1.0" encoding="utf-8"?>
;
; + 2nd level node is the sibling of the 1st level node. Don't have more than 1 2nd-level node.
; The actual tree starts from the 2nd level node.
; In this example, 2nd-level node is <tree> ... </tree>
;
; + 3rd level node must be inside 2nd-level node. It defines a package of files to be copied <package name="" startingsourcepath="" startingdestpath="">
; ++ [name] denotes the name of the package
; ++ [startingsourcepath] is optional. This denotes the start path of all the source files to be copied. If this attribute
; is not defined. The starting root path will default to the directory where this XML file is located
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
; ++ [startingdestpath] is required. This denotes the start path of where all the source files will be copied to.
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
;
; + 4th level node must be inside 3rd level node.
; Can have either of the following tags
; 1. <filescopy sourcedir="_" destdir="_"></filescopy>
; This allows user to specify what files to be copied from 1 source folder to 1 destination folder
; ++ [sourcedir] denotes the source directory where all the source file(s) resides.
; [sourcedir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
; if [sourcedir] is not defined, then all files defined within this node are to be created anew
; ++ [destdir] denotes the destination directory relative to the root dest dir
; [destdir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
;
; 2. <folderscopy sourcedir="_" destdir="_"/></folderscopy>
; This allows user to copy anything under the source folder to a destination folder. All files, folders
; and subfolders and subfiles will be copied to the destination folder
;
; + 5th level node must be inside 4th level node.
; Can have any combination of the following tags:
; 1. <fileinclude saveas="_" actions="_,_">filename</fileinclude>
; Description: Specifies file(s) to be copied
; ++ [saveas] is optional. Denotes to save the source file with a different name at the destination
; ++ [actions] is optional. Denotes the action to be perform on the file. Multiple actions are delimited
; with comma.
; Name of each action should be the same name defined by the Enum eFileAction that is defined
; in the frmBuildSoftwarePackage.cs.
; Possible actions are: CreateSWBuildIDEntries, BuildProjectUsingVS2009Compiler, BuildProjectUsingVS2010Compiler,
; BuildProjectInDebug, BuildProjectInRelease
;
; 2. <fileexclude>filename</fileinclude>
; Description: Specifies file(s) to be ignored
; ++ [filename] can be an actual file name or a wildcard such as "*.*" and "*.ext"
;
; Example 1 - Create a new file:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy destdir="dest">
; <fileinclude>newfile.txt</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 2 - Copy all the files in the root directory to "dest" directory in the root directory:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy sourcedir="." destdir=".\dest">
; <fileinclude>*.*</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 3 - Copy all files/folders/subfolders/subfiles within c:\source to c:\dest:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <folderscopy sourcedir="c:\source" destdir="c:\dest" />
; </package>
; </tree>
;=====================================================================================================================================
;
; REVISION HISTORY
;
; Date Programmer Proj. TEMA Title
; - - - - - - - - - - - - - - - - - - - - - - - - - -
; 061112 D.Le
;=====================================================================================================================================
-->
<tree>
<package name="Engineering PC Software Package" startingsourcepath="." startingdestpath="C:\ReleaseIB_Production">
<folderscopy sourcedir=".\GUTS" destdir="." />
<folderscopy sourcedir=".\CorecoFrameGrabber" destdir=".\CorecoFrameGrabber" />
</package>
</tree>

View File

@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
======================================================================================================================================
; FileName.xml
;=====================================================================================================================================
;
; Description or purpose:
; This XML file specifies all the directories and files that are
; to be copied/created from one source folder to one destination folder.
;
; Note/Restrictions:
; When commenting in this file, do not use 2 - adjacent to each other
; or the XML parser will hang. 2 hyphens adjacent to each other denote
; the start/end of a comment. Do not place comment at the top of the actual
; XML tags or the XML parser will hang.
;
; Usage:
; + 1st level node is the root, i.e. <?xml version="1.0" encoding="utf-8"?>
;
; + 2nd level node is the sibling of the 1st level node. Don't have more than 1 2nd-level node.
; The actual tree starts from the 2nd level node.
; In this example, 2nd-level node is <tree> ... </tree>
;
; + 3rd level node must be inside 2nd-level node. It defines a package of files to be copied <package name="" startingsourcepath="" startingdestpath="">
; ++ [name] denotes the name of the package
; ++ [startingsourcepath] is optional. This denotes the start path of all the source files to be copied. If this attribute
; is not defined. The starting root path will default to the directory where this XML file is located
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
; ++ [startingdestpath] is required. This denotes the start path of where all the source files will be copied to.
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
;
; + 4th level node must be inside 3rd level node.
; Can have either of the following tags
; 1. <filescopy sourcedir="_" destdir="_"></filescopy>
; This allows user to specify what files to be copied from 1 source folder to 1 destination folder
; ++ [sourcedir] denotes the source directory where all the source file(s) resides.
; [sourcedir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
; if [sourcedir] is not defined, then all files defined within this node are to be created anew
; ++ [destdir] denotes the destination directory relative to the root dest dir
; [destdir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
;
; 2. <folderscopy sourcedir="_" destdir="_"/></folderscopy>
; This allows user to copy anything under the source folder to a destination folder. All files, folders
; and subfolders and subfiles will be copied to the destination folder
;
; + 5th level node must be inside 4th level node.
; Can have any combination of the following tags:
; 1. <fileinclude saveas="_" actions="_,_">filename</fileinclude>
; Description: Specifies file(s) to be copied
; ++ [saveas] is optional. Denotes to save the source file with a different name at the destination
; ++ [actions] is optional. Denotes the action to be perform on the file. Multiple actions are delimited
; with comma.
; Name of each action should be the same name defined by the Enum eFileAction that is defined
; in the frmBuildSoftwarePackage.cs.
; Possible actions are: CreateSWBuildIDEntries, BuildProjectUsingVS2009Compiler, BuildProjectUsingVS2010Compiler,
; BuildProjectInDebug, BuildProjectInRelease
;
; 2. <fileexclude>filename</fileinclude>
; Description: Specifies file(s) to be ignored
; ++ [filename] can be an actual file name or a wildcard such as "*.*" and "*.ext"
;
; Example 1 - Create a new file:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy destdir="dest">
; <fileinclude>newfile.txt</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 2 - Copy all the files in the root directory to "dest" directory in the root directory:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy sourcedir="." destdir=".\dest">
; <fileinclude>*.*</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 3 - Copy all files/folders/subfolders/subfiles within c:\source to c:\dest:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <folderscopy sourcedir="c:\source" destdir="c:\dest" />
; </package>
; </tree>
;=====================================================================================================================================
;
; REVISION HISTORY
;
; Date Programmer Proj. TEMA Title
; - - - - - - - - - - - - - - - - - - - - - - - - - -
; 061112 D.Le
;=====================================================================================================================================
-->
<tree>
<package name="Engineering PC Support Package" startingsourcepath="." startingdestpath="C:\ReleaseIB_Production">
<filescopy destdir="C:\ReleaseIB_Production">
<fileinclude>PathLossLog.txt</fileinclude>
</filescopy>
<filescopy sourcedir=".\All" destdir=".\Utils">
<fileinclude>guts_startup_dev.pl</fileinclude>
<fileinclude>guts_startup.ini</fileinclude>
</filescopy>
<filescopy sourcedir=".\Engineering" destdir=".">
<fileinclude>Sm3Seeker.cfg</fileinclude>
</filescopy>
</package>
</tree>

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
======================================================================================================================================
; FileName.xml
;=====================================================================================================================================
;
; Description or purpose:
; This XML file specifies all the directories and files that are
; to be copied/created from one source folder to one destination folder.
;
; Note/Restrictions:
; When commenting in this file, do not use 2 - adjacent to each other
; or the XML parser will hang. 2 hyphens adjacent to each other denote
; the start/end of a comment. Do not place comment at the top of the actual
; XML tags or the XML parser will hang.
;
; Usage:
; + 1st level node is the root, i.e. <?xml version="1.0" encoding="utf-8"?>
;
; + 2nd level node is the sibling of the 1st level node. Don't have more than 1 2nd-level node.
; The actual tree starts from the 2nd level node.
; In this example, 2nd-level node is <tree> ... </tree>
;
; + 3rd level node must be inside 2nd-level node. It defines a package of files to be copied <package name="" startingsourcepath="" startingdestpath="">
; ++ [name] denotes the name of the package
; ++ [startingsourcepath] is optional. This denotes the start path of all the source files to be copied. If this attribute
; is not defined. The starting root path will default to the directory where this XML file is located
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
; ++ [startingdestpath] is required. This denotes the start path of where all the source files will be copied to.
; Path can be absolute or relative. If relative path, the path is relative to the directory where
; the XML resides, not where the EXE is located
;
; + 4th level node must be inside 3rd level node.
; Can have either of the following tags
; 1. <filescopy sourcedir="_" destdir="_"></filescopy>
; This allows user to specify what files to be copied from 1 source folder to 1 destination folder
; ++ [sourcedir] denotes the source directory where all the source file(s) resides.
; [sourcedir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
; if [sourcedir] is not defined, then all files defined within this node are to be created anew
; ++ [destdir] denotes the destination directory relative to the root dest dir
; [destdir] can start with "." which means start at the default/custom root directory.
; The default root directory is the directory where this XML file is located
;
; 2. <folderscopy sourcedir="_" destdir="_"/></folderscopy>
; This allows user to copy anything under the source folder to a destination folder. All files, folders
; and subfolders and subfiles will be copied to the destination folder
;
; + 5th level node must be inside 4th level node.
; Can have any combination of the following tags:
; 1. <fileinclude saveas="_" actions="_,_">filename</fileinclude>
; Description: Specifies file(s) to be copied
; ++ [saveas] is optional. Denotes to save the source file with a different name at the destination
; ++ [actions] is optional. Denotes the action to be perform on the file. Multiple actions are delimited
; with comma.
; Name of each action should be the same name defined by the Enum eFileAction that is defined
; in the frmBuildSoftwarePackage.cs.
; Possible actions are: CreateSWBuildIDEntries, BuildProjectUsingVS2009Compiler, BuildProjectUsingVS2010Compiler,
; BuildProjectInDebug, BuildProjectInRelease
;
; 2. <fileexclude>filename</fileinclude>
; Description: Specifies file(s) to be ignored
; ++ [filename] can be an actual file name or a wildcard such as "*.*" and "*.ext"
;
; Example 1 - Create a new file:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy destdir="dest">
; <fileinclude>newfile.txt</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 2 - Copy all the files in the root directory to "dest" directory in the root directory:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <filescopy sourcedir="." destdir=".\dest">
; <fileinclude>*.*</fileinclude>
; </filescopy>
; </package>
; </tree>
;
; Example 3 - Copy all files/folders/subfolders/subfiles within c:\source to c:\dest:
; <?xml version="1.0" encoding="utf-8"?>
;
; <tree>
; <package name="pkg1">
; <folderscopy sourcedir="c:\source" destdir="c:\dest" />
; </package>
; </tree>
;=====================================================================================================================================
;
; REVISION HISTORY
;
; Date Programmer Proj. TEMA Title
; - - - - - - - - - - - - - - - - - - - - - - - - - -
; 061112 D.Le
;=====================================================================================================================================
-->
<tree>
<package name="Package 1" startingsourcepath="..\" startingdestpath="..\CTS\CTS">
<filescopy sourcedir="." destdir="." overwriteallfiles="true">
<fileinclude>nuget.config</fileinclude>
</filescopy>
</package>
<package name="Package 2" startingsourcepath="{user_profile}" startingdestpath="..\CTS\CTS\Local_Nuget">
<filescopy sourcedir=".\.nuget\packages" destdir="." overwriteallfiles="true" recursive="true">
<fileinclude>*.nupkg</fileinclude>
</filescopy>
</package>
</tree>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<tree>
<package name="software_packages" startingsourcepath="{cd_drive}" startingdestpath="{user_temp_folder}\mk698">
<folderscopy cdlabel="MK698 Support Software Disc 1/2" overwriteallfiles="false" sourcedir="7-Zip" destdir="7-Zip" />
<filescopy cdlabel="MK698 Support Software Disc 1/2" overwritefiles="false" sourcedir="." destdir=".">
<fileinclude>MK698Software.7z.001</fileinclude>
</filescopy>
<filescopy cdlabel="MK698 Support Software Disc 2/2" overwritefiles="false" sourcedir="." destdir=".">
<fileinclude>MK698Software.7z.002</fileinclude>
</filescopy>
</package>
</tree>

View File

@@ -0,0 +1,746 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.Windows.Misc;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class NetworkAdapterManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
// this dictionary stores the application to be executed and the arguments associated with it
// it would look like this:
// [ c:\app1.exe ] -> [path arg arg_path]
// [ c:\app2.exe ] -> [path arg arg_path]
public Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> networkAdapterPciLocationToVarious = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
// event for thread to notify other threads that it has exited
private AutoResetEvent _resetEvent = new AutoResetEvent(false);
Form m_parentForm;
public NetworkAdapterManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool configureNetworkAdapters(string sectionName)
{
bool setupSuccessful = true;
string msg = "", msg2 = "", indentation = String.Empty, errMsg = "";
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList2 = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 10;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Configuring Network Adapters=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
networkAdapterPciLocationToVarious.Clear();
ConfigFileManager.readOneToManyDictionary(ConfigFileManager.ms_configGeneralInfo.iniFile,
sectionName, @"(nic\d+)_pci_location$", @"(nic\d+)_.+$", networkAdapterPciLocationToVarious);
setupSuccessful = verifyConfigInfo();
if (setupSuccessful)
{
if (networkAdapterPciLocationToVarious.Count == 0 ||
(networkAdapterPciLocationToVarious.Count == 1 && networkAdapterPciLocationToVarious.First().Value.Count == 0))
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. Nothing to configure";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
// for every app to be run
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in networkAdapterPciLocationToVarious)
{
string pciLocation = entry.Key.iniValue;
string networkAdapterName = "";
string networkAdapterIp = "";
string networkAdapterSubnetMask = "";
string networkAdapterDefaultGateway = "";
string networkAdapterLinkSpeed = "";
bool enableDhcp = false;
List<string> dnsServers = new List<string>();
getNicInfo(entry.Value, ref networkAdapterName, ref networkAdapterIp,
ref networkAdapterSubnetMask, ref networkAdapterDefaultGateway,
ref networkAdapterLinkSpeed, ref enableDhcp, ref dnsServers);
ManagementObject networkAdapter = null;
ManagementObject networkAdapterConfiguration = null;
setupSuccessful = NetworkManagement.GetNetworkAdapterAndConfigurationBasedOnPciLocation(ref networkAdapter, ref networkAdapterConfiguration, pciLocation, ref errMsg);
if (!setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. No network card is associated with PCI Location: " + pciLocation;
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
if (setupSuccessful && networkAdapterLinkSpeed.Length > 0)
{
setupSuccessful = NetworkManagement.SetNetworkAdapterLinkSpeed(networkAdapter, networkAdapterConfiguration, networkAdapterLinkSpeed, ref errMsg);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Setting link speed to " + networkAdapterLinkSpeed + " for network adapter at PCI Location " + pciLocation;
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
if (setupSuccessful && networkAdapterName.Length > 0)
{
setupSuccessful = NetworkManagement.ChangeNetworkAdapterName(networkAdapter, networkAdapterConfiguration, networkAdapterName, ref errMsg);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Setting adapter name to " + networkAdapterName + " for network adapter at PCI Location " + pciLocation;
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
if (setupSuccessful)
{
if (enableDhcp)
{
setupSuccessful = NetworkManagement.SetNetworkAdapterForDhcp(networkAdapter, networkAdapterConfiguration, ref errMsg);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Enabling DHCP for network adapter at PCI Location " + pciLocation;
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
else
{
if (setupSuccessful && networkAdapterIp.Length > 0 && networkAdapterSubnetMask.Length > 0)
{
setupSuccessful = NetworkManagement.SetNetworkAdapterIpAddress(networkAdapterConfiguration, networkAdapterIp, networkAdapterSubnetMask, ref errMsg);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Setting IP=" + networkAdapterIp + " and subnet=" + networkAdapterSubnetMask + " for network adapter at PCI Location " + pciLocation;
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
if (setupSuccessful && networkAdapterDefaultGateway.Length > 0 )
{
setupSuccessful = NetworkManagement.SetNetworkAdapterDefaultGateway(networkAdapterConfiguration, networkAdapterDefaultGateway, ref errMsg);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Setting default gateway=" + networkAdapterDefaultGateway + " for network adapter at PCI Location " + pciLocation;
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
if (setupSuccessful && dnsServers.Count > 0)
{
setupSuccessful = NetworkManagement.SetNetworkAdapterDnsServers(networkAdapter, networkAdapterConfiguration, dnsServers, ref errMsg);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Setting DNS Server1=" + dnsServers[0];
if (dnsServers.Count > 1)
msg += " and Server2=" + dnsServers[1];
msg += " for network adapter at PCI Location " + pciLocation;
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS";
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
}
}
if (!setupSuccessful)
break;
}
}
return setupSuccessful;
}
// get all the necessary info if user choose to verify software by looking at the registry
public void getNicInfo(List<ConfigFileManager.Ini_KeyValue<string>> iniKeys,
ref string networkAdapterName,
ref string networkAdapterIp, ref string networkAdapterSubnetMask,
ref string networkAdapterDefaultGateway, ref string networkAdapterLinkSpeed,
ref bool enableDhcp, ref List<string> dnsServers)
{
// for every key specified for the app to be installed/checked
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in iniKeys)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_adapter_name$", RegexOptions.IgnoreCase))
{
networkAdapterName = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_ip_and_subnet$", RegexOptions.IgnoreCase))
{
string[] ips = iniKey.iniValue.Split(',');
networkAdapterIp = ips[0].Trim();
networkAdapterSubnetMask = ips[1].Trim();
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_default_gateway$", RegexOptions.IgnoreCase))
{
networkAdapterDefaultGateway = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_link_speed$", RegexOptions.IgnoreCase))
{
networkAdapterLinkSpeed = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_enable_dhcp$", RegexOptions.IgnoreCase))
{
if (String.Equals(iniKey.iniValue, "true", StringComparison.OrdinalIgnoreCase))
enableDhcp = true;
else
enableDhcp = false;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_dns_servers$", RegexOptions.IgnoreCase))
{
string[] ips = iniKey.iniValue.Split(',');
ips[0] = ips[0].Trim();
if (ips.Length > 1)
ips[1] = ips[1].Trim();
dnsServers = new List<string>(ips);
}
}
}
bool verifyConfigInfo()
{
bool setupSuccessful = true;
ConfigFileManager.Ini_KeyValue<string> iniVal = new ConfigFileManager.Ini_KeyValue<string>("");
string indentation = String.Empty;
string msg;
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// for every app name to be installed, verify that each app name has the required information specified in the INI file
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in networkAdapterPciLocationToVarious)
{
if (!Regex.IsMatch(entry.Key.iniValue, @"\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*", RegexOptions.IgnoreCase))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Key: " + entry.Key.iniKeyName
+ "\n" + indentation + "Value: " + entry.Key.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. The value must be in format: #,#,# (i.e.: 1,25,0)";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
// for every key specified for the app to be installed
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in entry.Value)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"(nic\d+)_link_speed$", RegexOptions.IgnoreCase))
{
uint linkSpeed = 0;
if (iniKey.iniValue.Length == 0 || !UInt32.TryParse(iniKey.iniValue, out linkSpeed))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. Value must be a number";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_adapter_name", RegexOptions.IgnoreCase))
{
if (iniKey.iniValue.Length == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_ip_and_subnet", RegexOptions.IgnoreCase))
{
if (iniKey.iniValue.Length == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else
{
string[] ips = iniKey.iniValue.Split(',');
ips[0] = ips[0].Trim();
if ( ips.Length > 1)
ips[1] = ips[1].Trim();
List<string> ipList = new List<string>(ips);
if (ipList.Count != 2)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. Expecting IP address and subnet mask separated by comma";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else
{
if (!StringManip.IsValidIPv4(ips[0]))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. The IP specified is an invalid IPv4 address.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else if (ipList.Count > 1 && !StringManip.IsValidIPv4(ips[1]))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. The subnet mask specified is an invalid IPv4 address.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
}
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_default_gateway", RegexOptions.IgnoreCase))
{
if (iniKey.iniValue.Length == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else
{
if (!StringManip.IsValidIPv4(iniKey.iniValue))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. The gateway specified is an invalid IPv4 address.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"nic\d+_dns_servers", RegexOptions.IgnoreCase))
{
if (iniKey.iniValue.Length == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else
{
string[] ips = iniKey.iniValue.Split(',');
ips[0] = ips[0].Trim();
if (ips.Length > 1)
ips[1] = ips[1].Trim();
List<string> ipList = new List<string>(ips);
if (ipList.Count > 2)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. Expecting at least one DNS server, maximum 2 separated by comma";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else
{
if (!StringManip.IsValidIPv4(ips[0]))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. The 1st DNS Server specified is an invalid IPv4 address.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else if (ipList.Count > 1 && !StringManip.IsValidIPv4(ips[1]))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. The 2nd DNS Server specified is an invalid IPv4 address.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
}
}
}
if (!setupSuccessful)
break;
}
return setupSuccessful;
}
}
}

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace All_Purpose_Auto_Setup
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmMain());
}
}
}

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("Sm3_Block_IB_GUTS_Setup")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Raytheon")]
[assembly: AssemblyProduct("Sm3_Block_IB_GUTS_Setup")]
[assembly: AssemblyCopyright("Copyright © Raytheon 2016")]
[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("e3d2c81c-7b82-4780-ae92-06910e189973")]
// 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.6")]
[assembly: AssemblyFileVersion("1.0")]

View File

@@ -0,0 +1,73 @@
//------------------------------------------------------------------------------
// <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 All_Purpose_Auto_Setup.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("All_Purpose_Auto_Setup.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap sm3missile {
get {
object obj = ResourceManager.GetObject("sm3missile", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="sm3missile" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\sm3missile.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -0,0 +1,62 @@
//------------------------------------------------------------------------------
// <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 All_Purpose_Auto_Setup.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.9.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.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string ConfigFile {
get {
return ((string)(this["ConfigFile"]));
}
set {
this["ConfigFile"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool AutoRunOnStartup {
get {
return ((bool)(this["AutoRunOnStartup"]));
}
set {
this["AutoRunOnStartup"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("-1")]
public int CurrentSetupStep {
get {
return ((int)(this["CurrentSetupStep"]));
}
set {
this["CurrentSetupStep"] = value;
}
}
}
}

View File

@@ -0,0 +1,15 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="All_Purpose_Automated_Windows_Setup.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ConfigFile" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AutoRunOnStartup" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="CurrentSetupStep" Type="System.Int32" Scope="User">
<Value Profile="(Default)">-1</Value>
</Setting>
</Settings>
</SettingsFile>

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

View File

@@ -0,0 +1,911 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class RunApplicationsManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
public event Action<string, int, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAtLine;
// this dictionary stores the application to be executed and the arguments associated with it
// it would look like this:
// [ c:\app1.exe ] -> [path arg arg_path]
// [ c:\app2.exe ] -> [path arg arg_path]
public Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> runAppToArguments = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
// event for thread to notify other threads that it has exited
private AutoResetEvent _resetEvent = new AutoResetEvent(false);
int m_progressLine = 0;
string m_consoleAppStatusMessage = "";
Form m_parentForm;
public RunApplicationsManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool runApplications(string sectionName)
{
bool setupSuccessful = true;
string msg, indentation = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 10;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Running applications=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
runAppToArguments.Clear();
ConfigFileManager.readOneToManyDictionary(ConfigFileManager.ms_configGeneralInfo.iniFile,
sectionName, @"(app\d+)_path$", @"(app\d+)_.+$", runAppToArguments);
if (setupSuccessful)
{
if (runAppToArguments.Count == 0 ||
(runAppToArguments.Count == 1 && runAppToArguments.First().Value.Count == 0))
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. Nothing to run";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> processedConfigInfo = new KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
// for every app to be run
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in runAppToArguments)
{
string appDescription = "";
string appArg = "";
bool isConsoleApp = false;
bool waitForExit = true;
string cdLabel = "";
string displayMessage = "";
setupSuccessful = processConfigInfo(entry, ref processedConfigInfo);
if (!setupSuccessful)
break;
getAppInfo(processedConfigInfo.Value, ref appDescription, ref appArg, ref isConsoleApp, ref waitForExit, ref cdLabel, ref displayMessage);
setupSuccessful = startApp(appDescription, processedConfigInfo.Key.alternateValue, appArg, isConsoleApp, waitForExit, cdLabel, displayMessage);
if (!setupSuccessful)
break;
}
}
return setupSuccessful;
}
public bool startApp(string appDescription, string appPath, string appArguments, bool isConsoleApp, bool waitForExit, string cdLabel, string displayMessage)
{
string msg1 = String.Empty, msg2 = String.Empty, msg3, indentation = String.Empty, tempMsg = string.Empty;
bool setupSuccessful = true;
Match regExMatch;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList1 = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList2 = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
indentation = Common.getIndentation(1);
appPath = Path.GetFullPath(appPath);
// the argument may specify equal sign in it. But since INI files doesn't allow = to be
// specified in the value of they key, we have to specify <eq> in place of =.
// so now we replace instances of <eq> with =
appArguments = Regex.Replace(appArguments, @"<eq>", "=", RegexOptions.IgnoreCase);
if (appDescription.Length == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(233, 31, 195);
textProp.wordIndex = 1;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList1.Add(textProp);
msg1 = "\n" + indentation + "Running " + StringManip.ShortenStringToSize(appPath, 60);
msg2 = "\n" + indentation + "Running " + appPath;
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(233, 31, 195);
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList1.Add(textProp);
msg1 = "\n" + indentation + appDescription;
msg2 = "\n" + indentation + appDescription;
}
foreach (var drive in DriveInfo.GetDrives()
.Where(d => d.DriveType == DriveType.CDRom))
{
if (Regex.IsMatch(appPath, @"^" + Regex.Escape(drive.Name) + @".+", RegexOptions.IgnoreCase))
{
while (!drive.IsReady || !File.Exists(appPath))
{
Hardware.OpenCdDrive(drive.Name);
tempMsg = "Please insert a disc";
if (cdLabel.Length > 0)
tempMsg += " labeled \"" + cdLabel + "\"";
tempMsg += " into drive " + drive.Name + " that has the following path:\n" + appPath + "\n\n Click OK to proceed";
msg3 = ((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.OKCANCEL, null,
tempMsg, "Info", -1);
if (String.Equals(msg3, "cancel", StringComparison.OrdinalIgnoreCase))
{
break;
}
}
break;
}
}
if (File.Exists(appPath))
{
if (displayMessage.Length > 0)
{
displayMessage = Regex.Replace(displayMessage, @"\{newline\}", "\n");
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.INFO, null, displayMessage, "Info", -1);
}
BackgroundWorker bgwInformUserToWait;
bgwInformUserToWait = new BackgroundWorker();
bgwInformUserToWait.WorkerSupportsCancellation = true;
bgwInformUserToWait.DoWork += new DoWorkEventHandler(bgwInformUserToWait_DoWork);
bgwInformUserToWait.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwInformUserToWait_RunWorkerCompleted);
frmSetupStatusDisplay displayFrm = (frmSetupStatusDisplay)m_parentForm;
m_progressLine = displayFrm.updateStatusDisplayAndLog("\n ", "", null);
if (!bgwInformUserToWait.IsBusy)
{
indentation = Common.getIndentation(1);
if (appDescription.Length == 0)
{
bgwInformUserToWait.RunWorkerAsync(indentation + "Running " + Path.GetFileName(appPath) + ". Please wait");
}
else
{
bgwInformUserToWait.RunWorkerAsync(indentation + appDescription + ". Please wait");
}
}
try
{
regExMatch = Regex.Match(appPath, @"\.bat$", RegexOptions.IgnoreCase);
// if we're executing a bat file
if (regExMatch.Success)
{
ProcessStartInfo ProcStartInfo = new ProcessStartInfo(@"C:\Windows\System32\cmd.exe");
ProcStartInfo.RedirectStandardOutput = false;
ProcStartInfo.UseShellExecute = false;
ProcStartInfo.CreateNoWindow = true;
ProcStartInfo.RedirectStandardError = true;
System.Diagnostics.Process process = new System.Diagnostics.Process();
ProcStartInfo.Arguments = "/c start /wait /d \"" + Path.GetDirectoryName(appPath) + "\" " + Path.GetFileName(appPath);
process.StartInfo = ProcStartInfo;
process.Start();
if (waitForExit)
{
process.WaitForExit();
int exitCode = process.ExitCode;
process.Close();
if (exitCode != 0)
throw new Exception(Path.GetFileName(appPath) + " exited with code: " + exitCode.ToString());
}
}
else if (isConsoleApp)
{
ProcessStartInfo cmdStartInfo = new ProcessStartInfo();
cmdStartInfo.FileName = @"C:\Windows\System32\cmd.exe";
cmdStartInfo.RedirectStandardOutput = true;
cmdStartInfo.RedirectStandardError = true;
cmdStartInfo.RedirectStandardInput = true;
cmdStartInfo.UseShellExecute = false;
cmdStartInfo.CreateNoWindow = true;
Process process = new Process();
process.StartInfo = cmdStartInfo;
process.ErrorDataReceived += cmd_Error;
process.OutputDataReceived += cmd_DataReceived;
process.EnableRaisingEvents = true;
process.Start();
process.BeginOutputReadLine();
process.BeginErrorReadLine();
process.StandardInput.WriteLine(appPath + " " + appArguments); //Execute command
process.StandardInput.WriteLine("exit"); //Execute exit.
if (waitForExit)
{
process.WaitForExit();
int exitCode = process.ExitCode;
process.Close();
if (exitCode != 0)
{
if (appReturnedFatalError(appPath, exitCode, ""))
{
throw new Exception(Path.GetFileName(appPath) + " exited with code: " + exitCode.ToString() + ". " + m_consoleAppStatusMessage);
}
}
}
}
else
{
var process = Process.Start(appPath, appArguments);
if (waitForExit)
{
process.WaitForExit();
int exitCode = process.ExitCode;
process.Close();
if (exitCode != 0)
throw new Exception(Path.GetFileName(appPath) + " exited with code: " + exitCode.ToString());
}
}
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg3 = " - SUCCESS";
}
catch (Exception e)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg3 = " - FAILED. Error executing file " + appPath + ". " + e.Message;
setupSuccessful = false;
}
finally
{
if (!bgwInformUserToWait.CancellationPending && bgwInformUserToWait.IsBusy)
{
bgwInformUserToWait.CancelAsync();
_resetEvent.WaitOne();
_resetEvent.Reset();
}
displayFrm.removeStatusDisplayLine(m_progressLine, true);
}
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg3 = " - FAILED. File " + appPath + " was not found.";
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg1, msg2, textPropList1);
UpdateStatusDisplayAndLogEvent(msg3, msg3, textPropList2);
return setupSuccessful;
}
void cmd_DataReceived(object sender, DataReceivedEventArgs e)
{
if (e.Data == null)
{
return;
}
if (e.Data.Length > 0)
{
// since we are receiving everything that's being output to the standard output
// we're only interested in the response of the command, and not the command itself
if ( !Regex.IsMatch(e.Data, @"^[a-zA-Z]:[^>]+>.+", RegexOptions.IgnoreCase))
m_consoleAppStatusMessage = e.Data;
}
}
void cmd_Error(object sender, DataReceivedEventArgs e)
{
if (e.Data == null)
{
return;
}
if (e.Data.Length > 0)
{
// since we are receiving everything that's being output to the standard output
// we're only interested in the response of the command, and not the command itself
if (!Regex.IsMatch(e.Data, @"^[a-zA-Z]:[^>]+>.+", RegexOptions.IgnoreCase))
m_consoleAppStatusMessage = e.Data;
}
}
private bool appReturnedFatalError(string appPath, int errCode, string errMsg)
{
bool fatalError = true;
if (Regex.IsMatch(appPath, @"c:\\windows\\system32\\taskkill.exe", RegexOptions.IgnoreCase))
{
if (errCode == 128)
fatalError = false;
}
return fatalError;
}
private void bgwInformUserToWait_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// First, handle the case where an exception was thrown.
if (e.Error != null)
{
}
else if (e.Cancelled) // user cancelled
{
}
else // thread completed on its own
{
}
_resetEvent.Set(); // signal that execution of this thread is done
}
private void bgwInformUserToWait_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bgw = sender as BackgroundWorker;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
string text = (string)e.Argument;
string dots = "";
while (true)
{
if (bgw != null && bgw.CancellationPending)
{
if (e != null)
e.Cancel = true;
break;
}
if (dots.Length < 3)
dots += ".";
else
dots = ".";
if (StringManip.GetPhraseWordIndexInText(text, "running") > -1)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(157, 150, 19);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(text, "running");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 13, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(42, 176, 173);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(text, "running") + 1;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(text, "please wait") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 13, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(157, 150, 19);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(text, "please wait");
textProp.wordCount = 10;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 13, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(17, 75, 237);
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 13, FontStyle.Bold);
textPropList.Add(textProp);
}
UpdateStatusDisplayAtLine(text + dots, m_progressLine, textPropList);
Thread.Sleep(500);
}
}
// get all the necessary info if user choose to verify software by looking at the registry
public void getAppInfo(List<ConfigFileManager.Ini_KeyValue<string>> iniKeys, ref string appDescription, ref string appArg, ref bool isConsoleApp, ref bool waitForExit, ref string cdLabel, ref string displayMessage)
{
appDescription = "";
appArg = "";
displayMessage = "";
isConsoleApp = false;
waitForExit = true;
// for every key specified for the app to be installed/checked
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in iniKeys)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"app\d+_description$", RegexOptions.IgnoreCase))
{
appDescription = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"app\d+_argument$", RegexOptions.IgnoreCase))
{
appArg = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"app\d+_cd_label$", RegexOptions.IgnoreCase))
{
cdLabel = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"app\d+_display_message_to_user$", RegexOptions.IgnoreCase))
{
displayMessage = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"app\d+_is_console$", RegexOptions.IgnoreCase))
{
if (String.Equals(iniKey.iniValue, "true", StringComparison.OrdinalIgnoreCase))
isConsoleApp = true;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"app\d+_wait_for_exit$", RegexOptions.IgnoreCase))
{
if (String.Equals(iniKey.iniValue, "true", StringComparison.OrdinalIgnoreCase))
waitForExit = true;
else
waitForExit = false;
}
}
}
bool processConfigInfo(KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry,
ref KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> processedEntry)
{
string fileExt = "";
bool setupSuccessful = true;
ConfigFileManager.Ini_KeyValue<string> iniVal = new ConfigFileManager.Ini_KeyValue<string>("");
ConfigFileManager.Ini_KeyValue<string> iniVal2 = new ConfigFileManager.Ini_KeyValue<string>("");
string indentation = String.Empty;
string msg = "", msg2 = "";
Match regExMatch;
int matchedArgumentIndex = -1;
Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> tempOneToManyDict = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
Dictionary<string, string> idToPath = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
iniVal = entry.Key;
bool appTypeSpecified = false;
string appId = "";
regExMatch = Regex.Match(entry.Key.iniKeyName, @"(app\d+)_.+$", RegexOptions.IgnoreCase);
if (regExMatch.Success)
appId = regExMatch.Groups[1].Value;
// process the key of the map which contains the setup file path
if (!Common.pathContainsMacro(entry.Key.iniValue))
{
regExMatch = Regex.Match(entry.Key.iniValue, @".*\{browse_to_file:([^\}]+)\}.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
fileExt = Path.GetExtension(regExMatch.Groups[1].Value);
msg = "Please browse to location where file \"" + regExMatch.Groups[1].Value + "\" is located at";
regExMatch = Regex.Match(entry.Key.iniValue, @".*\{message_to_user:([^\}]+)\}.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
msg += "\n" + regExMatch.Groups[1].Value;
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.INFO, null, msg, "Info", -1);
m_parentForm.Invoke((MethodInvoker)(() =>
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = Application.StartupPath;
openFileDialog1.Filter = "File (*" + fileExt + ")|*" + fileExt;
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
iniVal.alternateValue = openFileDialog1.FileName;
}
}));
if (iniVal.alternateValue.Length == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Key: " + entry.Key.iniKeyName
+ "\n" + indentation + "Value: " + entry.Key.iniValue
+ "\n" + indentation + "Error Description: User did not provide a valid file";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
}
else
{
iniVal.alternateValue = Path.GetFullPath(entry.Key.iniValue);
// check only relative path
if (!Path.IsPathRooted(entry.Key.iniValue) && (!File.Exists(iniVal.alternateValue)))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Key: " + entry.Key.iniKeyName
+ "\n" + indentation + "Value: " + entry.Key.iniValue
+ "\n" + indentation + "Error Description: The path defined in the value above is invalid. Translated path " + iniVal.alternateValue;
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
}
}
else // the path specified contains macros, we have to resolve macros
{
iniVal.alternateValue = Common.resolveMacroPath(entry.Key.iniValue);
if (Common.pathContainsCdDriveMacro(entry.Key.iniValue))
{
if (iniVal.alternateValue.Length == 0)
{
setupSuccessful = false;
msg2 = PathManip.enumWindowsDesignatedPaths.CD_DRIVE.ToString() + " macro was defined. But no CD drive is found in the system";
}
//else
//{
// setupSuccessful = Common.validatePathInCdDrive(iniVal.alternateValue, m_parentForm);
// if ( !setupSuccessful )
// msg2 = "\"" + iniVal.alternateValue + "\" does not exist. Please insert a CD with that path";
//}
if (!setupSuccessful)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Key: " + entry.Key.iniKeyName
+ "\n" + indentation + "Value: " + entry.Key.iniValue
+ "\n" + indentation + "Error Description: " + msg2;
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
}
// process the values of the map which contains various related things like application argument, description, is_console, wait_for_exit, etc
if (setupSuccessful)
{
tempOneToManyDict[iniVal] = new List<ConfigFileManager.Ini_KeyValue<string>>(entry.Value);
matchedArgumentIndex = tempOneToManyDict[iniVal].FindIndex(x => Regex.IsMatch(x.iniKeyName, @"app\d+_argument$", RegexOptions.IgnoreCase));
// for every key specified for the app to be run
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in entry.Value)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"(app\d+)_is_console$", RegexOptions.IgnoreCase))
{
appTypeSpecified = true;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"(app\d+)_argument$", RegexOptions.IgnoreCase))
{
iniVal2 = tempOneToManyDict[iniVal][matchedArgumentIndex];
regExMatch = Regex.Match(iniKey.iniValue, @".*\{browse_to_file:([^\}]+)\}.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
fileExt = Path.GetExtension(regExMatch.Groups[1].Value);
msg = "Please browse to location where file \"" + regExMatch.Groups[1].Value + "\" is located at";
regExMatch = Regex.Match(iniKey.iniValue, @".*\{message_to_user:([^\}]+)\}.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
msg += "\n" + regExMatch.Groups[1].Value;
((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.INFO, null, msg, "Info", -1);
m_parentForm.Invoke((MethodInvoker)(() =>
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = Application.StartupPath;
openFileDialog1.Filter = "File (*" + fileExt + ")|*" + fileExt;
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
iniVal2.iniValue = openFileDialog1.FileName;
tempOneToManyDict[iniVal][matchedArgumentIndex] = iniVal2;
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniVal2.iniSectionName
+ "\n" + indentation + "Key: " + iniVal2.iniKeyName
+ "\n" + indentation + "Value: " + iniVal2.iniValue
+ "\n" + indentation + "Error Description: User did not provide a valid file";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
}));
}
else
{
// matches every macro defined in the value of they key, macro is in the form of {xxxxx} such as {user_desktop}, {user_temp_folder}, {cd_drive}, {keyname}
MatchCollection matches = Regex.Matches(iniKey.iniValue, @"\{([^\{\}]+)\}", RegexOptions.IgnoreCase);
if (matches.Count > 0)
{
// each match can have multiple parts i.e. $1 $2...$n
for (int i = 0; i < matches.Count; i++)
{
// matches[i].Groups[0].Value is the actual macro itself, i.e. {keyname}
// matches[i].Groups[1].Value is the string inside curly brackets, i.e. keyname
string pattern = Regex.Escape(matches[i].Groups[1].Value);
// looking for a key that defines the actual path to be used in the argument
int matchedPathIndex = entry.Value.FindIndex(x => Regex.IsMatch(x.iniKeyName, pattern, RegexOptions.IgnoreCase));
// if the macro in the argument refers to another key the defines a path
if (matchedPathIndex >= 0 && !idToPath.ContainsKey(matches[i].Groups[0].Value))
{
if (PathManip.PathIsFile(entry.Value[matchedPathIndex].iniValue))
idToPath[matches[i].Groups[0].Value] = Path.GetDirectoryName(Path.GetFullPath(entry.Value[matchedPathIndex].iniValue));
else
idToPath[matches[i].Groups[0].Value] = Path.GetFullPath(entry.Value[matchedPathIndex].iniValue);
}
// if the macro in the argument refers to the path defined by primary key app#_path
else if (String.Equals(entry.Key.iniKeyName, matches[i].Groups[1].Value, StringComparison.OrdinalIgnoreCase) && !idToPath.ContainsKey(matches[i].Groups[0].Value))
{
if (PathManip.PathIsFile(iniVal.alternateValue))
idToPath[matches[i].Groups[0].Value] = Path.GetDirectoryName(Path.GetFullPath(iniVal.alternateValue));
else
idToPath[matches[i].Groups[0].Value] = Path.GetFullPath(iniVal.alternateValue);
}
// if the macro refers to user's desktop, temp folder, cd drive
else if (Common.pathContainsMacro(matches[i].Groups[0].Value))
{
if (!idToPath.ContainsKey(matches[i].Groups[0].Value))
{
string resolvedPath = Common.resolveMacroPath(matches[i].Groups[0].Value);
if (Common.pathContainsCdDriveMacro(matches[i].Groups[0].Value))
{
if (resolvedPath.Length == 0)
{
setupSuccessful = false;
msg2 = matches[i].Groups[1].Value + " macro was defined. But no CD drive is found in the system";
}
if (!setupSuccessful)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: " + msg2;
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
if (setupSuccessful)
idToPath[matches[i].Groups[0].Value] = resolvedPath;
}
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value above specifies a variable \"" + matches[i].Groups[0].Value + "\" in the argument."
+ " Key \"" + iniKey.iniKeyName + "_" + matches[i].Groups[1].Value
+ "\" must be defined to specify the actual path for variable \"" + matches[i].Groups[0].Value + "\"";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
}
}
if (!setupSuccessful)
break;
}
}
}
if (setupSuccessful && !appTypeSpecified)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Error Description: The key name \"" + appId + "_is_console\" is missing in the above section in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
if (setupSuccessful)
{
if (idToPath.Count > 0)
{
// goes through each marco in the argument ini key and replace with actual paths
foreach (KeyValuePair<string, string> item in idToPath)
{
if (matchedArgumentIndex >= 0)
{
iniVal2 = tempOneToManyDict[iniVal][matchedArgumentIndex];
iniVal2.iniValue = Regex.Replace(iniVal2.iniValue, Regex.Escape(item.Key), item.Value, RegexOptions.IgnoreCase);
tempOneToManyDict[iniVal][matchedArgumentIndex] = iniVal2;
}
}
}
processedEntry = new KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>(iniVal, new List<ConfigFileManager.Ini_KeyValue<string>>(tempOneToManyDict[iniVal]));
}
return setupSuccessful;
}
}
}

View File

@@ -0,0 +1,453 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
using CommonLib.Windows.Misc;
namespace All_Purpose_Auto_Setup
{
class SetupMiscellaneous
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
public Dictionary<string, string> environmentVars = new Dictionary<string, string>();
public Dictionary<string, string> userPrompt = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
Form m_parentForm;
public SetupMiscellaneous(Form parentForm)
{
m_parentForm = parentForm;
}
public bool setEnvironmentVariables(string sectionName)
{
bool setupSuccessful = true;
string msg;
string indentation = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Setting System Environment Variables=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
environmentVars.Clear();
ConfigFileManager.parseConfigInfo(sectionName, environmentVars);
if (setupSuccessful)
{
if (environmentVars.Count == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. Nothing to set";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
foreach (KeyValuePair<string, string> entry in environmentVars)
{
if (String.Equals(entry.Key, "path", StringComparison.OrdinalIgnoreCase))
{
setupSuccessful = processPathEnvironmentVariable(entry.Value);
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + entry.Key + "=" + entry.Value;
try
{
System.Environment.SetEnvironmentVariable(entry.Key, entry.Value, EnvironmentVariableTarget.Machine);
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
catch (Exception e)
{
msg += " - FAILED. (" + e.Message;
uint code = (uint)e.HResult;
if (code == 0x8013150a)
{
msg += " Need ADMIN privilege.";
}
msg += ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
if (!setupSuccessful)
break;
}
}
return setupSuccessful;
}
public bool processPathEnvironmentVariable(string value)
{
bool setupSuccessful = true;
string msg;
string indentation = String.Empty, currentPathEnvVar = "";
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
List<string> newPathList = new List<string>(value.Split(','));
try
{
currentPathEnvVar = System.Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Machine);
}
catch (Exception e)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Querying system environment variable \"Path\" - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
if (setupSuccessful)
{
List<string> currentPathList = new List<string>(currentPathEnvVar.Split(';'));
indentation = Common.getIndentation(1);
foreach (string item in newPathList)
{
string path = item.Trim();
if (currentPathList.Count == 0)
{
currentPathEnvVar = path;
msg = "\n" + indentation + " Path=" + path;
try
{
System.Environment.SetEnvironmentVariable("Path", currentPathEnvVar, EnvironmentVariableTarget.Machine);
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
catch (Exception e)
{
msg += " - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
}
else if (currentPathList.FindIndex(x => x == path) < 0 && currentPathList.FindIndex(x => x == PathManip.RemoveTrailingSlashInPath(path)) < 0)
{
currentPathEnvVar += ";" + path;
msg = "\n" + indentation + " Path={Path};" + path;
try
{
System.Environment.SetEnvironmentVariable("Path", currentPathEnvVar, EnvironmentVariableTarget.Machine);
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
catch (Exception e)
{
msg += " - FAILED. (" + e.Message;
uint code = (uint)e.HResult;
if (code == 0x8013150a)
{
msg += " Need ADMIN privilege.";
}
msg += ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
}
else
{
msg = "\n" + indentation + "Path=" + "{Path};" + path;
msg += " - SKIPPED. " + path + " already exists in {Path}";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SKIPPED.");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
if (!setupSuccessful)
break;
}
}
return setupSuccessful;
}
public bool promptUser(string sectionName)
{
bool setupSuccessful = true;
string msg, displayMsg, result;
string indentation = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=User Prompt=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
userPrompt.Clear();
ConfigFileManager.parseConfigInfo(sectionName, userPrompt);
if (setupSuccessful)
{
if (userPrompt.Count == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. No-operation";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
else
{
if (!userPrompt.ContainsKey("prompt_message"))
{
msg = "\n" + indentation + "- FAILED. (Expecting key \"prompt_message\" in section \"" + sectionName + "\")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
if (setupSuccessful)
{
if (!userPrompt.ContainsKey("prompt_message_type"))
{
msg = "\n" + indentation + "- FAILED. Expecting key \"prompt_message_type\" in section \"" + sectionName + "\"";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
}
if (setupSuccessful)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "Promp user";
displayMsg = Regex.Replace(userPrompt["prompt_message"], @"\{newline\}", "\n");
if ( String.Equals(userPrompt["prompt_message_type"], MessageBoxCustom.PopUpMsgType.YESNO.ToString(), StringComparison.CurrentCultureIgnoreCase))
result = ((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.YESNO, null, displayMsg, "Info", -1);
else if (String.Equals(userPrompt["prompt_message_type"], MessageBoxCustom.PopUpMsgType.OKCANCEL.ToString(), StringComparison.CurrentCultureIgnoreCase))
result = ((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.OKCANCEL, null, displayMsg, "Info", -1);
else
result = ((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.INFO, null, displayMsg, "Info", -1);
if ( Regex.IsMatch(result, @"(yes|ok)", RegexOptions.IgnoreCase))
{
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
msg += " - FAILED. (User selected to abort the operation)";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
}
return setupSuccessful;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,555 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
namespace All_Purpose_Auto_Setup
{
class WindowFeaturesManager
{
List<string> iisFeatures = new List<string>();
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
public event Action<string, int, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAtLine;
// event for thread to notify other threads that it has exited
private AutoResetEvent _resetEvent = new AutoResetEvent(false);
public ConfigFileManager.Ini_KeyValue<string> windowsFeatureListFile = new ConfigFileManager.Ini_KeyValue<string>("");
Form m_parentForm;
List<string> iisFeaturesToBeInstalled = new List<string>();
private bool windowFeatureInstalledSuccessful = false;
private bool needElevatedPermission = false;
private bool otherErrorOccurred = false;
private string dismErrorMsg = "";
private int windowFeatureState = 1;
private string currentWindowFeature;
int m_progressLine = 0;
public WindowFeaturesManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool enableWindowsOptionalFeatures(string sectionName)
{
bool setupSuccessful = true;
string msg;
string indentation = String.Empty;
int featureInstalledCount = 0;
currentWindowFeature = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
BackgroundWorker bgwInformUserToWait;
bgwInformUserToWait = new BackgroundWorker();
bgwInformUserToWait.WorkerSupportsCancellation = true;
bgwInformUserToWait.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwInformUserToWait_RunWorkerCompleted);
bgwInformUserToWait.DoWork += new DoWorkEventHandler(bgwInformUserToWait_DoWork);
ProcessStartInfo cmdStartInfo = new ProcessStartInfo();
cmdStartInfo.FileName = @"C:\Windows\System32\cmd.exe";
cmdStartInfo.RedirectStandardOutput = true;
cmdStartInfo.RedirectStandardError = true;
cmdStartInfo.RedirectStandardInput = true;
cmdStartInfo.UseShellExecute = false;
cmdStartInfo.CreateNoWindow = true;
Process cmdProcess;
//cmdProcess.StandardInput.WriteLine("Dism /online /disable-feature /featurename:IIS-FTPSvc /norestart"); //Execute command
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Enabling Windows Features=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
parseConfigInfo(sectionName);
setupSuccessful = verifyConfigInfo();
frmSetupStatusDisplay displayFrm = (frmSetupStatusDisplay)m_parentForm;
if (setupSuccessful)
{
getWindowsFeatures(iisFeatures);
m_progressLine = displayFrm.updateStatusDisplayAndLog("\n ", "", textPropList);
if (!bgwInformUserToWait.IsBusy)
{
indentation = Common.getIndentation(1);
bgwInformUserToWait.RunWorkerAsync(indentation + "Gathering information about windows features to be installed. Please wait");
}
windowFeatureState = 1;
cmdProcess = new Process();
cmdProcess.StartInfo = cmdStartInfo;
cmdProcess.ErrorDataReceived += cmd_Error;
cmdProcess.OutputDataReceived += cmd_WindowFeature_DataReceived;
cmdProcess.EnableRaisingEvents = true;
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
cmdProcess.BeginErrorReadLine();
string system32Directory = Path.Combine(Environment.ExpandEnvironmentVariables("%windir%"), "sysnative", "dism.exe");
cmdProcess.StandardInput.WriteLine(system32Directory + " /online /get-features"); //Execute command
cmdProcess.StandardInput.WriteLine("exit"); //Execute exit.
cmdProcess.WaitForExit();
cmdProcess.Close();
if (!bgwInformUserToWait.CancellationPending && bgwInformUserToWait.IsBusy)
{
bgwInformUserToWait.CancelAsync();
_resetEvent.WaitOne();
_resetEvent.Reset();
}
windowFeatureState++;
displayFrm.removeStatusDisplayLine(m_progressLine, true);
if (needElevatedPermission)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. Need administrator privilege to access Windows Features.";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
else if (otherErrorOccurred)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. " + dismErrorMsg;
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
else if (iisFeaturesToBeInstalled.Count == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. All necessary windows features are already enabled.";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
else
{
m_progressLine = displayFrm.updateStatusDisplayAndLog("\n ", "", textPropList);
int featureCountLine = m_progressLine;
foreach (string feature in iisFeaturesToBeInstalled)
{
indentation = Common.getIndentation(1);
msg = indentation + "Features enabled: " + featureInstalledCount.ToString() + " / " + iisFeaturesToBeInstalled.Count.ToString();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = 2;
textProp.wordCount = 10;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 10, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAtLine(msg, featureCountLine, textPropList);
m_progressLine = displayFrm.updateStatusDisplayAndLog("\n ", "", textPropList);
if (!bgwInformUserToWait.IsBusy)
{
indentation = Common.getIndentation(1);
bgwInformUserToWait.RunWorkerAsync(indentation + "Enabling " + feature + ". Please wait");
}
windowFeatureInstalledSuccessful = false;
dismErrorMsg = "";
cmdProcess = new Process();
cmdProcess.StartInfo = cmdStartInfo;
cmdProcess.ErrorDataReceived += cmd_Error;
cmdProcess.OutputDataReceived += cmd_WindowFeature_DataReceived;
cmdProcess.EnableRaisingEvents = true;
cmdProcess.Start();
cmdProcess.BeginOutputReadLine();
cmdProcess.BeginErrorReadLine();
cmdProcess.StandardInput.WriteLine(system32Directory + " /online /enable-feature /featurename:" + feature + " /all /norestart"); //Execute command
cmdProcess.StandardInput.WriteLine("exit"); //Execute exit.
cmdProcess.WaitForExit();
cmdProcess.Close();
if (!bgwInformUserToWait.CancellationPending && bgwInformUserToWait.IsBusy)
{
bgwInformUserToWait.CancelAsync();
_resetEvent.WaitOne();
_resetEvent.Reset();
}
displayFrm.removeStatusDisplayLine(m_progressLine, true);
if (!windowFeatureInstalledSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n" + Common.getIndentation(1) + "- FAILED. Failed enabling " + feature + "." + dismErrorMsg;
setupSuccessful = false;
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
break;
}
else
{
featureInstalledCount++;
msg = indentation + "Features enabled: " + featureInstalledCount.ToString() + " / " + iisFeaturesToBeInstalled.Count.ToString();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(5, 112, 1);
textProp.wordIndex = 2;
textProp.wordCount = 10;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 10, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAtLine(msg, featureCountLine, textPropList);
msg = "\n" + Common.getIndentation(1) + "Enabling " + feature + " - SUCCESS";
UpdateStatusDisplayAndLogEvent("", msg, textPropList);
}
}
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n" + Common.getIndentation(1) + "- SUCCESS";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
}
return setupSuccessful;
}
void getWindowsFeatures(List<string> featureList)
{
string line;
StreamReader file = new StreamReader(windowsFeatureListFile.iniValue);
while ((line = file.ReadLine()) != null)
{
line = line.Trim();
if (line.Length > 0)
iisFeatures.Add(line);
}
file.Close();
}
private void bgwInformUserToWait_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// First, handle the case where an exception was thrown.
if (e.Error != null)
{
}
else if (e.Cancelled) // user cancelled
{
}
else // thread completed on its own
{
}
_resetEvent.Set();
}
private void bgwInformUserToWait_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bgw = sender as BackgroundWorker;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
string text = (string)e.Argument;
string dots = "";
while (true)
{
if (bgw != null && bgw.CancellationPending)
{
if (e != null)
e.Cancel = true;
break;
}
if (dots.Length < 3)
dots += ".";
else
dots = ".";
if (StringManip.GetPhraseWordIndexInText(text, "enabling") > -1)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(157, 150, 19);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(text, "enabling");
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 11, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(42, 176, 173);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(text, "enabling") + 1;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(text, "please wait") - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 11, FontStyle.Bold);
textPropList.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(157, 150, 19);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(text, "please wait");
textProp.wordCount = 10;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 11, FontStyle.Bold);
textPropList.Add(textProp);
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(17, 75, 237);
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont.FontFamily, 13, FontStyle.Bold);
textPropList.Add(textProp);
}
UpdateStatusDisplayAtLine(text + dots, m_progressLine, textPropList);
Thread.Sleep(500);
}
}
void cmd_WindowFeature_DataReceived(object sender, DataReceivedEventArgs e)
{
Match regExMatch;
string result;
if (e.Data == null)
{
return;
}
if (windowFeatureState == 1)
{
regExMatch = Regex.Match(e.Data, @"error: 740", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
needElevatedPermission = true;
}
if (otherErrorOccurred && e.Data.Length > 0)
{
dismErrorMsg += ". " + e.Data;
}
regExMatch = Regex.Match(e.Data, @"error: \d+", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
otherErrorOccurred = true;
dismErrorMsg += e.Data;
}
regExMatch = Regex.Match(e.Data, @"feature name\s+:\s+(.+)$", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
currentWindowFeature = regExMatch.Groups[1].Value;
}
regExMatch = Regex.Match(e.Data, @"state\s+:\s+disabled", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
result = iisFeatures.Find(item => item == currentWindowFeature);
if (result != null && result.Length > 0)
{
iisFeaturesToBeInstalled.Add(result);
}
}
}
else
{
if (otherErrorOccurred && e.Data.Length > 0)
{
dismErrorMsg += ". " + e.Data;
}
regExMatch = Regex.Match(e.Data, @"error: \d+", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
otherErrorOccurred = true;
dismErrorMsg += e.Data;
}
regExMatch = Regex.Match(e.Data, @".*successfully.*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
windowFeatureInstalledSuccessful = true;
}
}
}
void cmd_Error(object sender, DataReceivedEventArgs e)
{
//Console.WriteLine("Error from other process");
//Console.WriteLine(e.Data);
}
private void parseConfigInfo(string sectionName)
{
windowsFeatureListFile.iniSectionName = sectionName;
windowsFeatureListFile.iniKeyName = "windows_feature_list_file";
windowsFeatureListFile.iniValue = ConfigFileManager.ms_configGeneralInfo.iniFile.ReadValue(sectionName, windowsFeatureListFile.iniKeyName);
}
bool verifyConfigInfo()
{
bool setupSuccessful = true;
ConfigFileManager.Ini_KeyValue<string> iniVal = new ConfigFileManager.Ini_KeyValue<string>("");
string indentation = String.Empty;
string msg, tempPath;
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
if (windowsFeatureListFile.iniValue.Length > 0)
{
tempPath = Path.GetFullPath(windowsFeatureListFile.iniValue);
if (!File.Exists(tempPath))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + windowsFeatureListFile.iniSectionName
+ "\n" + indentation + "Key: " + windowsFeatureListFile.iniKeyName
+ "\n" + indentation + "Value: " + windowsFeatureListFile.iniValue
+ "\n" + indentation + "Error Description: The path defined in the value above is invalid. Translated path " + tempPath;
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
}
else
windowsFeatureListFile.iniValue = tempPath;
}
return setupSuccessful;
}
}
}

View File

@@ -0,0 +1,604 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
using CommonLib.Windows.Misc;
namespace All_Purpose_Auto_Setup
{
class WindowsRegistryManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
// this dictionary stores registry path and its associated properties
// it would look like this:
// [ reg1_path ] -> List[reg1_action,reg1_type, etc]
// [ reg2_path ] -> List[reg2_action,reg2_type, etc]
public Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> regPathToVariousThings = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
Form m_parentForm;
public WindowsRegistryManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool ModifyWindowsRegistry(string sectionName)
{
bool setupSuccessful = true;
string msg;
string indentation = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
string registryPath, registryType, registryAction;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Modifying Windows Registry=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
regPathToVariousThings.Clear();
ConfigFileManager.readOneToManyDictionary(ConfigFileManager.ms_configGeneralInfo.iniFile,
sectionName, @"(reg\d+)_path$", @"(reg\d+)_.+", regPathToVariousThings);
setupSuccessful = verifyConfigInfo();
if (setupSuccessful)
{
if (regPathToVariousThings.Count == 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. Nothing to set";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
// for every app name to be installed/checked
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in regPathToVariousThings)
{
registryPath = entry.Key.iniValue;
registryType = "";
registryAction = "";
Dictionary<string, string> registryNameValuePairs = new Dictionary<string, string>();
getRegistryInfo(entry.Value, ref registryAction, ref registryType, registryNameValuePairs);
registryAction = registryAction.Trim();
registryType = registryType.Trim();
setupSuccessful = modifyRegistryKey(registryPath, registryType, registryAction, registryNameValuePairs);
if (!setupSuccessful)
break;
}
}
return setupSuccessful;
}
public bool modifyRegistryKey(string registryPath, string registryType, string registryAction, Dictionary<string, string> registryNameValuePairs)
{
bool setupSuccessful = true;
string errMsg = "", msg1 = "", msg2 = "", indentation = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList1 = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList2 = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
Match regExMatch;
indentation = Common.getIndentation(1);
if (registryNameValuePairs.Count > 0)
{
foreach (KeyValuePair<string, string> entry in registryNameValuePairs)
{
msg1 = "";
if (String.Equals(registryAction, "delete", StringComparison.OrdinalIgnoreCase))
{
setupSuccessful = WindowsRegistry.DeleteRegistryValueName(registryPath, getRegistryHive(registryType), entry.Key, ref errMsg);
msg1 = "\n" + indentation + "Deleting value name " + entry.Key + " in " + registryPath;
}
else // add to registry
{
// match single-value registry value name
regExMatch = Regex.Match(entry.Value, @"^\s*value\s*:\s*(.*[^\s])\s*,\s*type\s*:\s*(.*[a-zA-Z])\s*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
List<string> pair = new List<string>() { regExMatch.Groups[1].Value, regExMatch.Groups[2].Value };
if (getRegistryValueKind(pair[1]) != RegistryValueKind.MultiString)
setupSuccessful = WindowsRegistry.AddOrModifyRegistryKeySingleValue(registryPath, getRegistryHive(registryType), entry.Key, getRegistryValueKind(pair[1]), pair[0], ref errMsg);
else
{
setupSuccessful = false;
errMsg = "Expected a value name of type single value (string, dword, qword). Actual type is multi-string";
}
msg1 = "\n" + indentation + "Setting value name " + entry.Key + "=" + pair[0] + " in " + registryPath;
}
else
{
// match multi-string registry value name
regExMatch = Regex.Match(entry.Value, @"^(\s*:\s*value\s*:\s*.*[^\s])\s*,\s*type\s*:\s*(.*[a-zA-Z])\s*", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
List<string> pair = new List<string>() { regExMatch.Groups[1].Value, regExMatch.Groups[2].Value };
List<string> values = new List<string>(regExMatch.Groups[1].Value.Split(new string[] { ":value:" }, StringSplitOptions.RemoveEmptyEntries));
if (getRegistryValueKind(pair[1]) == RegistryValueKind.MultiString)
{
setupSuccessful = WindowsRegistry.AddOrModifyRegistryKeyMultiStringValue(registryPath, getRegistryHive(registryType), entry.Key, values, ref errMsg);
}
else
{
setupSuccessful = false;
errMsg = "Expected a value name of type multi-string. Actual type is single value (string, qword, dword)";
}
msg1 = "\n" + indentation + "Setting value name " + entry.Key + "={";
string tempStr = "";
foreach (string val in values)
{
if (tempStr.Length > 0)
tempStr += ";";
tempStr += val;
}
msg1 += tempStr + "} in " + registryPath;
}
}
}
if ( msg1.Length > 0 )
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(233, 31, 195);
textProp.wordIndex = 3;
textProp.wordCount = StringManip.GetPhraseWordIndexInText(msg1, "in " + registryPath) - textProp.wordIndex;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList1.Add(textProp);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(233, 31, 195);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg1, "in " + registryPath) + 1;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList1.Add(textProp);
if (errMsg.Length > 0 && !setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
else if (errMsg.Length > 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SKIPPED. " + errMsg;
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS.";
}
UpdateStatusDisplayAndLogEvent(msg1, msg1, textPropList1);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
if (!setupSuccessful)
break;
}
}
else // add/delete registry path
{
if (String.Equals(registryAction, "delete", StringComparison.OrdinalIgnoreCase))
{
setupSuccessful = WindowsRegistry.DeleteRegistryKey(registryPath, getRegistryHive(registryType), ref errMsg);
msg1 = "\n" + indentation + "Deleting key " + registryPath;
}
else // add name/value to registry key
{
// only creating path
setupSuccessful = WindowsRegistry.AddOrModifyRegistryKeySingleValue(registryPath, getRegistryHive(registryType), "", RegistryValueKind.String, "", ref errMsg);
msg1 = "\n" + indentation + "Creating key " + registryPath;
}
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Color.FromArgb(233, 31, 195);
textProp.wordIndex = 2;
textProp.wordCount = 100;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList1.Add(textProp);
if (errMsg.Length > 0 && !setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - FAILED. " + errMsg;
}
else if (errMsg.Length > 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SKIPPED. " + errMsg;
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList2.Add(textProp);
msg2 = " - SUCCESS.";
}
UpdateStatusDisplayAndLogEvent(msg1, msg1, textPropList1);
UpdateStatusDisplayAndLogEvent(msg2, msg2, textPropList2);
}
return setupSuccessful;
}
public RegistryValueKind getRegistryValueKind(string valueKind)
{
RegistryValueKind regValueKind = RegistryValueKind.String;
if (String.Equals(valueKind, WindowsRegistry.valueKind.DWORD.ToString(), StringComparison.OrdinalIgnoreCase))
{
regValueKind = RegistryValueKind.DWord;
}
else if (String.Equals(valueKind, WindowsRegistry.valueKind.QWORD.ToString(), StringComparison.OrdinalIgnoreCase))
{
regValueKind = RegistryValueKind.QWord;
}
else if (String.Equals(valueKind, WindowsRegistry.valueKind.MULTI_STRING.ToString(), StringComparison.OrdinalIgnoreCase))
{
regValueKind = RegistryValueKind.MultiString;
}
return regValueKind;
}
public void getRegistryInfo(List<ConfigFileManager.Ini_KeyValue<string>> iniKeys, ref string action,
ref string registryType, Dictionary<string,string> nameValuePairs)
{
Match regExMatch;
registryType = "";
action = "";
// for every key specified for the app to be installed/checked
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in iniKeys)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"reg\d+_action$", RegexOptions.IgnoreCase))
{
action = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"reg\d+_type", RegexOptions.IgnoreCase))
{
registryType = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"reg\d+_name_value_pair", RegexOptions.IgnoreCase))
{
regExMatch = Regex.Match(iniKey.iniValue, @"\[\s*name\s*:\s*(.*[^\s])\s*,\s*value\s*:\s*(.*[^\s])\s*,\s*type\s*:\s*(.*[a-zA-Z])\s*\]", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
if (!nameValuePairs.ContainsKey(regExMatch.Groups[1].Value))
{
nameValuePairs[regExMatch.Groups[1].Value] = "value:" + regExMatch.Groups[2].Value + ",type:" + regExMatch.Groups[3].Value;
}
}
else
{
regExMatch = Regex.Match(iniKey.iniValue, @"\[\s*name\s*:\s*([^,]*[^\s,])\s*\]", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
if (!nameValuePairs.ContainsKey(regExMatch.Groups[1].Value))
{
nameValuePairs[regExMatch.Groups[1].Value] = "";
}
}
}
if (!regExMatch.Success)
{
regExMatch = Regex.Match(iniKey.iniValue, @"\[\s*name\s*:\s*(.*[^\s])\s*,\s*:\s*value\s*:\s*(.*[^\s])\s*,\s*type\s*:\s*(.*[a-zA-Z])\s*\]", RegexOptions.IgnoreCase);
if (regExMatch.Success)
{
if (!nameValuePairs.ContainsKey(regExMatch.Groups[1].Value))
{
nameValuePairs[regExMatch.Groups[1].Value] = ":value:" + regExMatch.Groups[2].Value + ",type:" + regExMatch.Groups[3].Value;
}
}
}
}
}
}
public static bool registryTypeIsValid(string regType)
{
bool isValid = false;
if (String.Equals(regType, "local_machine", StringComparison.OrdinalIgnoreCase)
||
String.Equals(regType, "classes_root", StringComparison.OrdinalIgnoreCase)
||
String.Equals(regType, "current_user", StringComparison.OrdinalIgnoreCase))
{
isValid = true;
}
return isValid;
}
public static RegistryHive getRegistryHive(string regType)
{
RegistryHive regHive = RegistryHive.LocalMachine;
if (String.Equals(regType, "local_machine", StringComparison.OrdinalIgnoreCase))
regHive = RegistryHive.LocalMachine;
else if (String.Equals(regType, "classes_root", StringComparison.OrdinalIgnoreCase))
regHive = RegistryHive.ClassesRoot;
else if (String.Equals(regType, "current_user", StringComparison.OrdinalIgnoreCase))
regHive = RegistryHive.CurrentUser;
else
regHive = RegistryHive.LocalMachine;
return regHive;
}
bool verifyConfigInfo()
{
bool setupSuccessful = true;
ConfigFileManager.Ini_KeyValue<string> iniVal = new ConfigFileManager.Ini_KeyValue<string>("");
string indentation = String.Empty;
string msg;
Match regExMatch;
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
string registryAction = "";
string regId = "";
bool registryActionDefined = false;
bool registryTypeDefined = false;
// for every registry path defined
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in regPathToVariousThings)
{
registryActionDefined = false;
registryTypeDefined = false;
// for every key specified for this registry path
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in entry.Value)
{
regExMatch = Regex.Match(iniKey.iniKeyName, @"(reg\d+)_.+$", RegexOptions.IgnoreCase);
if (regExMatch.Success)
regId = regExMatch.Groups[1].Value;
if (Regex.IsMatch(iniKey.iniKeyName, @"reg\d+_action", RegexOptions.IgnoreCase))
{
registryActionDefined = true;
registryAction = iniKey.iniValue;
}
else if (Regex.IsMatch(iniKey.iniKeyName, @"reg\d+_type", RegexOptions.IgnoreCase))
{
registryTypeDefined = true;
if (!registryTypeIsValid(iniKey.iniValue))
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
}
if (registryActionDefined)
{
// for every key specified to be added/modified/delete
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in entry.Value)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"reg\d+_name_value_pair", RegexOptions.IgnoreCase))
{
if (String.Equals(registryAction, "delete", StringComparison.OrdinalIgnoreCase))
{
regExMatch = Regex.Match(iniKey.iniValue, @"\[\s*name\s*:\s*([^,]*[^\s,])\s*\]", RegexOptions.IgnoreCase);
}
else
{
// match single value
regExMatch = Regex.Match(iniKey.iniValue, @"\[\s*name\s*:\s*(.*[^\s])\s*,\s*value\s*:\s*(.*[^\s])\s*,\s*type\s*:\s*(.*[a-zA-Z])\s*\]", RegexOptions.IgnoreCase);
// match multi value
if ( !regExMatch.Success )
regExMatch = Regex.Match(iniKey.iniValue, @"\[\s*name\s*:\s*(.*[^\s])\s*,\s*:\s*value\s*:\s*(.*[^\s])\s*,\s*type\s*:\s*(.*[a-zA-Z])\s*\]", RegexOptions.IgnoreCase);
}
if (!regExMatch.Success)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + iniKey.iniSectionName
+ "\n" + indentation + "Key: " + iniKey.iniKeyName
+ "\n" + indentation + "Value: " + iniKey.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
}
}
if (!setupSuccessful)
break;
if (!registryActionDefined)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Error Description: The key name " + regId + "_action is missing in the above section in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
else if (!registryTypeDefined)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.Key.iniSectionName
+ "\n" + indentation + "Error Description: The key name " + regId + "_type is missing in the above section in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
setupSuccessful = false;
break;
}
}
return setupSuccessful;
}
}
}

View File

@@ -0,0 +1,331 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using System.Drawing;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
using CommonLib.Windows.Misc;
namespace All_Purpose_Auto_Setup
{
class WindowsShortcutManager
{
// An event that can be raised, allowing other classes to
// subscribe to it and do what they like with the message.
public event Action<string, string, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>> UpdateStatusDisplayAndLogEvent;
// this dictionary stores shortcut name and its associated target_path and arguments
// it would look like this:
// [ shortcut1_name ] -> List[target_path,arguments]
// [ shortcut2_name ] -> List[target_path,arguments]
public Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> shortcutNameToTargetAndArgs = new Dictionary<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>>();
Form m_parentForm;
public WindowsShortcutManager(Form parentForm)
{
m_parentForm = parentForm;
}
public bool creatShortcuts(string sectionName)
{
string indentation = String.Empty;
bool setupSuccessful = true;
string msg, msg2, shortcutArgs;
string tempPath = "";
string shortcutPath = String.Empty;
string shortcutTargetPath = String.Empty;
string shortcutLocation = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
bool createShortcut = true;
bool statusGiven = false;
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n-=Creating Windows Shortcuts=-";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
shortcutNameToTargetAndArgs.Clear();
ConfigFileManager.readOneToManyDictionary(ConfigFileManager.ms_configGeneralInfo.iniFile,
sectionName, @"(shortcut\d+)_name$", @"(shortcut\d+)_.+", shortcutNameToTargetAndArgs);
if (setupSuccessful)
{
foreach (KeyValuePair<ConfigFileManager.Ini_KeyValue<string>, List<ConfigFileManager.Ini_KeyValue<string>>> entry in shortcutNameToTargetAndArgs)
{
shortcutLocation = getShortcutLocation(entry.Value);
if (shortcutLocation.Length > 0)
{
shortcutPath = Path.Combine(shortcutLocation, entry.Key.iniValue) + ".lnk";
shortcutTargetPath = getShortcutTargetPath(entry.Value);
shortcutArgs = getShortcutArguments(entry.Value);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + shortcutPath;
if (String.Equals(PathManip.AddTrailingSlashToPath(shortcutLocation), PathManip.AddTrailingSlashToPath(PathManip.GetUserStartupFolderPath()), StringComparison.CurrentCultureIgnoreCase))
{
tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup), entry.Key.iniValue) + ".lnk";
if (File.Exists(tempPath))
{
msg += " - SKIPPED. This shortcut already exists for all users";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.USER_SKIP);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SKIPPED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
createShortcut = false;
if (!statusGiven)
statusGiven = true;
}
}
else if (String.Equals(PathManip.AddTrailingSlashToPath(shortcutLocation), PathManip.AddTrailingSlashToPath(PathManip.GetUserDesktopPath()), StringComparison.CurrentCultureIgnoreCase))
{
tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory), entry.Key.iniValue) + ".lnk";
if (File.Exists(tempPath))
{
msg += " - SKIPPED. This shortcut already exists for all users";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.USER_SKIP);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SKIPPED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
createShortcut = false;
if (!statusGiven)
statusGiven = true;
}
}
if (!statusGiven && File.Exists(shortcutPath))
{
msg2 = ((frmSetupStatusDisplay)m_parentForm).displayMessageBox(MessageBoxCustom.PopUpMsgType.YESNO, null, "Shortcut \"" + Path.GetFileName(shortcutPath) + "\" already exists.\n\nDo you wish to overwrite it?", "Warning!!!", -1);
if (!String.Equals(msg2, "yes", StringComparison.OrdinalIgnoreCase))
{
msg += " - SKIPPED. Shortcut already exists";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.USER_SKIP);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SKIPPED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
createShortcut = false;
if (!statusGiven)
statusGiven = true;
}
}
if (shortcutPath.Length == 0 || shortcutTargetPath.Length == 0 || shortcutLocation.Length == 0)
{
createShortcut = false;
}
if (createShortcut)
{
try
{
File.Delete(shortcutPath);
WindowShortcut.Create(shortcutPath, shortcutTargetPath, shortcutArgs, Path.GetDirectoryName(shortcutTargetPath), "", "", null);
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
}
catch (Exception e)
{
msg += " - FAILED. (" + e.Message + ")";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED."); ;
textProp.wordCount = 1;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
setupSuccessful = false;
}
if (!statusGiven)
statusGiven = true;
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
else
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. Unable to determine Windows Login Id";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
if (!statusGiven)
statusGiven = true;
break;
}
createShortcut = true;
}
if (!statusGiven)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SYSTEM_SKIP);
textProp.wordIndex = 0;
textProp.wordCount = 2;
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SKIPPED. No configuration info found";
UpdateStatusDisplayAndLogEvent(msg, msg, textPropList);
}
}
return setupSuccessful;
}
public string getShortcutTargetPath(List<ConfigFileManager.Ini_KeyValue<string>> iniKeys)
{
string targetPath = "";
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in iniKeys)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"shortcut\d+_target_path", RegexOptions.IgnoreCase))
{
targetPath = iniKey.iniValue;
break;
}
}
return targetPath;
}
public string getShortcutArguments(List<ConfigFileManager.Ini_KeyValue<string>> iniKeys)
{
string args = "";
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in iniKeys)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"shortcut\d+_arguments", RegexOptions.IgnoreCase))
{
args = iniKey.iniValue;
break;
}
}
return args;
}
public string getShortcutLocation(List<ConfigFileManager.Ini_KeyValue<string>> iniKeys)
{
string location = "";
foreach (ConfigFileManager.Ini_KeyValue<string> iniKey in iniKeys)
{
if (Regex.IsMatch(iniKey.iniKeyName, @"shortcut\d+_location", RegexOptions.IgnoreCase))
{
location = Common.resolveMacroPath(iniKey.iniValue);
if (String.IsNullOrEmpty(location))
{
if (Directory.Exists(iniKey.iniValue))
{
location = iniKey.iniValue;
}
}
}
}
return location;
}
}
}

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates application support for Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--The ID below indicates application support for Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--The ID below indicates application support for Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->
</asmv1:assembly>

117
AllPurposeAutoSetup/frmAbout.Designer.cs generated Normal file
View File

@@ -0,0 +1,117 @@
namespace All_Purpose_Auto_Setup
{
partial class frmAbout
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmAbout));
this.lblDescription = new System.Windows.Forms.Label();
this.btnOK = new System.Windows.Forms.Button();
this.lblAuthor = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// lblDescription
//
this.lblDescription.AutoSize = true;
this.lblDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblDescription.Location = new System.Drawing.Point(58, 130);
this.lblDescription.Name = "lblDescription";
this.lblDescription.Size = new System.Drawing.Size(76, 16);
this.lblDescription.TabIndex = 0;
this.lblDescription.Text = "Description";
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(273, 156);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(98, 31);
this.btnOK.TabIndex = 1;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// lblAuthor
//
this.lblAuthor.AutoSize = true;
this.lblAuthor.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblAuthor.Location = new System.Drawing.Point(9, 178);
this.lblAuthor.Name = "lblAuthor";
this.lblAuthor.Size = new System.Drawing.Size(56, 13);
this.lblAuthor.TabIndex = 2;
this.lblAuthor.Text = "Developer";
//
// pictureBox1
//
this.pictureBox1.Image = global::All_Purpose_Auto_Setup.Properties.Resources.sm3missile;
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(383, 100);
this.pictureBox1.TabIndex = 3;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(8, 103);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(227, 24);
this.label1.TabIndex = 4;
this.label1.Text = "All Purpose Auto Setup";
//
// frmAbout
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.ClientSize = new System.Drawing.Size(383, 196);
this.Controls.Add(this.label1);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.lblAuthor);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.lblDescription);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "frmAbout";
this.Text = "About";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lblDescription;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Label lblAuthor;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Reflection;
using System.IO;
using CommonLib.Windows.Forms;
namespace All_Purpose_Auto_Setup
{
public partial class frmAbout : ChildForm
{
public frmAbout()
{
InitializeComponent();
Version appVersion = Assembly.GetExecutingAssembly().GetName().Version;
DateTime buildDate = File.GetCreationTime(Assembly.GetExecutingAssembly().Location);
lblDescription.Text = "Version: " + appVersion.Major.ToString() + "." + appVersion.Minor.ToString() + "\n";
lblDescription.Text += "Last update: " + buildDate.ToString() + "\n";
lblAuthor.Text = "Developer: Duc Le";
}
private void btnOK_Click(object sender, EventArgs e)
{
this.Close();
}
}
}

File diff suppressed because it is too large Load Diff

170
AllPurposeAutoSetup/frmMain.Designer.cs generated Normal file
View File

@@ -0,0 +1,170 @@
namespace All_Purpose_Auto_Setup
{
partial class frmMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.btnStart = new System.Windows.Forms.Button();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.label1 = new System.Windows.Forms.Label();
this.btnSelectConfigFile = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.txtBoxConfigFile = new System.Windows.Forms.TextBox();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// btnStart
//
this.btnStart.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnStart.ForeColor = System.Drawing.Color.Purple;
this.btnStart.Location = new System.Drawing.Point(11, 80);
this.btnStart.Margin = new System.Windows.Forms.Padding(2);
this.btnStart.Name = "btnStart";
this.btnStart.Size = new System.Drawing.Size(127, 48);
this.btnStart.TabIndex = 0;
this.btnStart.Text = "START";
this.btnStart.UseVisualStyleBackColor = true;
this.btnStart.Click += new System.EventHandler(this.btnStart_Click);
//
// menuStrip1
//
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fileToolStripMenuItem,
this.helpToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 2, 0, 2);
this.menuStrip1.Size = new System.Drawing.Size(390, 24);
this.menuStrip1.TabIndex = 1;
this.menuStrip1.Text = "menuStrip1";
//
// fileToolStripMenuItem
//
this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
this.fileToolStripMenuItem.Text = "File";
//
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.aboutToolStripMenuItem});
this.helpToolStripMenuItem.Name = "helpToolStripMenuItem";
this.helpToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.helpToolStripMenuItem.Text = "Help";
//
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 20.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic))), System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.SystemColors.Highlight;
this.label1.Location = new System.Drawing.Point(-3, 33);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(200, 31);
this.label1.TabIndex = 2;
this.label1.Text = "Generic Setup";
//
// btnSelectConfigFile
//
this.btnSelectConfigFile.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnSelectConfigFile.Location = new System.Drawing.Point(3, 143);
this.btnSelectConfigFile.Name = "btnSelectConfigFile";
this.btnSelectConfigFile.Size = new System.Drawing.Size(190, 30);
this.btnSelectConfigFile.TabIndex = 3;
this.btnSelectConfigFile.Text = "Select Configuration File";
this.btnSelectConfigFile.UseVisualStyleBackColor = true;
this.btnSelectConfigFile.Click += new System.EventHandler(this.btnSelectConfigFile_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(6, 185);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(116, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Current Config File:";
//
// txtBoxConfigFile
//
this.txtBoxConfigFile.BackColor = System.Drawing.SystemColors.ButtonHighlight;
this.txtBoxConfigFile.Location = new System.Drawing.Point(123, 181);
this.txtBoxConfigFile.Name = "txtBoxConfigFile";
this.txtBoxConfigFile.ReadOnly = true;
this.txtBoxConfigFile.Size = new System.Drawing.Size(255, 20);
this.txtBoxConfigFile.TabIndex = 5;
//
// frmMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(390, 215);
this.Controls.Add(this.txtBoxConfigFile);
this.Controls.Add(this.label2);
this.Controls.Add(this.btnSelectConfigFile);
this.Controls.Add(this.label1);
this.Controls.Add(this.btnStart);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "frmMain";
this.Text = "Generic Setup";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_FormClosing);
this.Load += new System.EventHandler(this.frmMain_Load);
this.Shown += new System.EventHandler(this.frmMain_Shown);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button btnStart;
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem helpToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnSelectConfigFile;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtBoxConfigFile;
}
}

View File

@@ -0,0 +1,395 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Threading;
using System.Reflection;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
using CommonLib.Windows.Misc;
namespace All_Purpose_Auto_Setup
{
public partial class frmMain : Form
{
frmSetupStatusDisplay dlgBuildSoftwarePackage;
private bool restartApplicationRequested = false;
private bool rebootRequested = false;
string pathAndNameOfConfigFile = "";
public frmMain()
{
InitializeComponent();
Version appVersion = Assembly.GetExecutingAssembly().GetName().Version;
DateTime buildDateTime = File.GetCreationTime(Assembly.GetExecutingAssembly().Location);
this.Text = "Automated Windows Setup - " + buildDateTime.ToString("MM/dd/yyyy") + " - Version " + appVersion.Major.ToString() + "." + appVersion.Minor.ToString();
}
private void btnStart_Click(object sender, EventArgs e)
{
bool iniFileValid = false;
string msg = string.Empty;
while (!iniFileValid)
{
iniFileValid = true;
if (pathAndNameOfConfigFile == null || pathAndNameOfConfigFile.Length == 0)
{
msg = "INI file is not provided";
iniFileValid = false;
}
else if (!String.Equals(Path.GetExtension(pathAndNameOfConfigFile), ".ini", StringComparison.OrdinalIgnoreCase))
{
msg = "File " + pathAndNameOfConfigFile + " is not an INI file";
iniFileValid = false;
}
else if (!File.Exists(pathAndNameOfConfigFile))
{
iniFileValid = false;
msg = "INI File " + pathAndNameOfConfigFile + " doesn't exist";
}
msg += "\nPlease select a valid INI configuration file to continue...";
if (!iniFileValid)
{
List<MessageBoxCustom.clsCustomButton> buttons = new List<MessageBoxCustom.clsCustomButton>()
{ new MessageBoxCustom.clsCustomButton("Select File...", "0"),
new MessageBoxCustom.clsCustomButton("Cancel...", "1"),
};
string result = MessageBoxCustom.Show(this, MessageBoxCustom.PopUpMsgType.CUSTOMQUESTION, buttons, msg, "ERROR!!!", -1);
if (result == "0")
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = Application.StartupPath;
openFileDialog1.Filter = "INI File (*.ini)|*.ini";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pathAndNameOfConfigFile = openFileDialog1.FileName;
txtBoxConfigFile.Text = pathAndNameOfConfigFile;
processConfigFile();
}
}
else
break;
}
}
if (iniFileValid)
{
bool proceed = runApplicationUsingAdminAccount();
if (restartApplicationRequested)
{
this.Close();
}
else if (proceed)
{
// we only ask for login account if we're starting a new setup process
if ((int)Properties.Settings.Default["CurrentSetupStep"] < 1)
{
provideWindowsPasswordForAutoLogin();
}
dlgBuildSoftwarePackage = new frmSetupStatusDisplay(this);
dlgBuildSoftwarePackage.FormClosing += getReasonForSetupFormClosing;
dlgBuildSoftwarePackage.parentForm = this;
dlgBuildSoftwarePackage.ShowDialog();
if (restartApplicationRequested)
{
this.Close();
}
if (rebootRequested)
{
ProcessStartInfo proc = new ProcessStartInfo();
proc.WindowStyle = ProcessWindowStyle.Hidden;
proc.FileName = "cmd";
proc.Arguments = "/C shutdown -r -t 1";
Process.Start(proc);
this.Close();
}
}
}
}
public string getConfigFile()
{
return pathAndNameOfConfigFile;
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
frmAbout dlgAbout = new frmAbout();
dlgAbout.parentForm = this;
DialogResult result = dlgAbout.ShowDialog();
}
void getReasonForSetupFormClosing(Object sender, FormClosingEventArgs e)
{
if (dlgBuildSoftwarePackage.restartApplicationRequested)
restartApplicationRequested = true;
if (dlgBuildSoftwarePackage.rebootRequested)
rebootRequested = true;
}
private void frmMain_Shown(object sender, EventArgs e)
{
string[] args = Environment.GetCommandLineArgs();
if (args.Count() > 1)
{
pathAndNameOfConfigFile = args[1];
if (!PathManip.IsAbsolutePath(pathAndNameOfConfigFile))
pathAndNameOfConfigFile = Path.GetFullPath(Path.Combine(Application.StartupPath, pathAndNameOfConfigFile));
}
else if (Properties.Settings.Default["ConfigFile"].ToString().Length > 0)
{
pathAndNameOfConfigFile = Properties.Settings.Default["ConfigFile"].ToString();
}
else if (pathAndNameOfConfigFile.Length == 0)
{
pathAndNameOfConfigFile = Path.Combine(Application.StartupPath, "config.ini");
}
txtBoxConfigFile.Text = pathAndNameOfConfigFile;
processConfigFile();
if ((bool)Properties.Settings.Default["AutoRunOnStartup"])
{
Properties.Settings.Default["AutoRunOnStartup"] = false;
Common.deleteTaskSchedulerForAutoRunAfterReboot("Auto_Win_Setup_Task");
btnStart.PerformClick();
}
}
private void processConfigFile()
{
if (pathAndNameOfConfigFile.Length > 0 && File.Exists(pathAndNameOfConfigFile))
{
IniFileManip iniFile = new IniFileManip(pathAndNameOfConfigFile);
string sectionName = ConfigFileManager.enum_INI_SECTION_NAMES.General.ToString();
string program = iniFile.ReadValue(sectionName, "program_name");
if (program.Length > 0)
{
this.label1.Text = program;
}
}
}
private bool runApplicationUsingAdminAccount()
{
bool proceed = true;
string msg = "";
if (pathAndNameOfConfigFile.Length > 0 && File.Exists(pathAndNameOfConfigFile))
{
IniFileManip iniFile = new IniFileManip(pathAndNameOfConfigFile);
string sectionName = ConfigFileManager.enum_INI_SECTION_NAMES.Global_Settings.ToString();
string provideAdminAccount = iniFile.ReadValue(sectionName, "Always_Run_Application_Using_Admin_Account");
if (String.Equals(provideAdminAccount, "true", StringComparison.OrdinalIgnoreCase)
||
String.Equals(provideAdminAccount, "yes", StringComparison.OrdinalIgnoreCase))
{
// if application is not run using an admin account
if (!WindowsAdministration.IsApplicationRunAsAdmin())
{
msg = "This software application must be run using an Administrator account.\n\nClick OK to run this application using an Administrator account.";
MessageBoxCustom.Show(this, MessageBoxCustom.PopUpMsgType.INFO, null, msg, "INFO", -1);
ProcessStartInfo proc = new ProcessStartInfo();
proc.UseShellExecute = true;
proc.WorkingDirectory = Environment.CurrentDirectory;
proc.FileName = Application.ExecutablePath;
proc.Arguments = pathAndNameOfConfigFile;
proc.Verb = "runas";
try
{
this.Hide();
Process.Start(proc);
restartApplicationRequested = true;
}
catch
{
this.Show();
proceed = false;
// The user refused the elevation.
// Do nothing and return directly ...
//return;
}
}
}
}
return proceed;
}
private void provideWindowsPasswordForAutoLogin()
{
if (pathAndNameOfConfigFile.Length > 0 && File.Exists(pathAndNameOfConfigFile))
{
IniFileManip iniFile = new IniFileManip(pathAndNameOfConfigFile);
string sectionName = ConfigFileManager.enum_INI_SECTION_NAMES.Global_Settings.ToString();
string provideAdminAccount = iniFile.ReadValue(sectionName, "Provide_Windows_Password_For_Auto_Login");
if (String.Equals(provideAdminAccount, "true", StringComparison.OrdinalIgnoreCase)
||
String.Equals(provideAdminAccount, "yes", StringComparison.OrdinalIgnoreCase))
{
enableWindowsAutoLogin();
}
}
}
private void enableWindowsAutoLogin()
{
string errMsg = "";
string password = "";
string password2 = "";
string registryPath = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon";
frmUserInput inputDialog = new frmUserInput(this);
inputDialog.parentForm = this;
do
{
inputDialog.richTxtBoxOverwriteText("There might be one or more reboots during the setup process.\n\n");
inputDialog.richTxtBoxAppendText("Please provide the password for " + WindowsAdministration.GetWindowLoginID() + " so that the application can auto-login to continue the setup process.\n");
inputDialog.richTxtBoxAppendText("If there's no password, leave the field blank.");
inputDialog.ShowDialog();
password = inputDialog.getUserPassword();
if (password.Length > 0)
{
inputDialog.richTxtBoxOverwriteText("Please re-enter the password.");
inputDialog.clearUserPassword();
inputDialog.ShowDialog();
password2 = inputDialog.getUserPassword();
inputDialog.clearUserPassword();
if (password != password2)
{
MessageBoxCustom.Show(this, MessageBoxCustom.PopUpMsgType.ERROR, null, "The passwords you entered do not match. Please re-enter the password.", "ERROR!!!", -1);
}
}
} while (password.Length > 0 && password != password2);
string username = Regex.Replace(WindowsAdministration.GetWindowLoginID(), @"[^\\]+\\(.+)", "$1");
WindowsRegistry.AddOrModifyRegistryKeySingleValue(registryPath, Microsoft.Win32.RegistryHive.LocalMachine, "AutoAdminLogon", Microsoft.Win32.RegistryValueKind.String, "1", ref errMsg);
if (WindowsAdministration.GetDomainName() != System.Environment.MachineName)
{
WindowsRegistry.AddOrModifyRegistryKeySingleValue(registryPath, Microsoft.Win32.RegistryHive.LocalMachine, "DefaultDomainName", Microsoft.Win32.RegistryValueKind.String, WindowsAdministration.GetDomainName(), ref errMsg);
}
WindowsRegistry.AddOrModifyRegistryKeySingleValue(registryPath, Microsoft.Win32.RegistryHive.LocalMachine, "DefaultUserName", Microsoft.Win32.RegistryValueKind.String, username, ref errMsg);
if (password.Length > 0)
WindowsRegistry.AddOrModifyRegistryKeySingleValue(registryPath, Microsoft.Win32.RegistryHive.LocalMachine, "DefaultPassword", Microsoft.Win32.RegistryValueKind.String, password, ref errMsg);
}
private void frmMain_Load(object sender, EventArgs e)
{
this.AllowDrop = true;
this.DragEnter += frmMain_DragEnter;
this.DragDrop += frmMain_DragDrop;
}
private void frmMain_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Copy;
}
else
{
e.Effect = DragDropEffects.None;
}
}
private void frmMain_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
string[] filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));
if (filePaths.Length > 1)
{
MessageBoxCustom.Show(this, MessageBoxCustom.PopUpMsgType.ERROR, null, "More than one file detected. Expecting only one file of type INI", "ERROR!!!", -1);
}
else if (!String.Equals(Path.GetExtension(filePaths[0]), ".ini", StringComparison.OrdinalIgnoreCase))
{
MessageBoxCustom.Show(this, MessageBoxCustom.PopUpMsgType.ERROR, null, "Wrong file type detected. Expecting only file of type INI", "ERROR!!!", -1);
}
else
{
pathAndNameOfConfigFile = filePaths[0];
processConfigFile();
}
}
}
private void btnSelectConfigFile_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (pathAndNameOfConfigFile.Length > 0)
{
openFileDialog1.InitialDirectory = Path.GetDirectoryName(pathAndNameOfConfigFile);
}
else
openFileDialog1.InitialDirectory = Application.StartupPath;
openFileDialog1.Filter = "INI File (*.ini)|*.ini";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pathAndNameOfConfigFile = openFileDialog1.FileName;
txtBoxConfigFile.Text = pathAndNameOfConfigFile;
processConfigFile();
}
}
private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default["ConfigFile"] = pathAndNameOfConfigFile;
Properties.Settings.Default.Save();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,81 @@
namespace All_Purpose_Auto_Setup
{
partial class frmSetupStatusDisplay
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmSetupStatusDisplay));
this.statusRtxtbox = new System.Windows.Forms.RichTextBox();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// statusRtxtbox
//
this.statusRtxtbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.statusRtxtbox.Cursor = System.Windows.Forms.Cursors.IBeam;
this.statusRtxtbox.HideSelection = false;
this.statusRtxtbox.Location = new System.Drawing.Point(-1, 0);
this.statusRtxtbox.Margin = new System.Windows.Forms.Padding(2);
this.statusRtxtbox.Name = "statusRtxtbox";
this.statusRtxtbox.Size = new System.Drawing.Size(726, 554);
this.statusRtxtbox.TabIndex = 0;
this.statusRtxtbox.Text = "";
//
// btnCancel
//
this.btnCancel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnCancel.Location = new System.Drawing.Point(322, 558);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(75, 33);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "CANCEL";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// frmSetupStatusDisplay
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(725, 596);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.statusRtxtbox);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Margin = new System.Windows.Forms.Padding(2);
this.Name = "frmSetupStatusDisplay";
this.Text = "Setup Status";
this.Shown += new System.EventHandler(this.frmSetupStatusDisplay_Shown);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.RichTextBox statusRtxtbox;
private System.Windows.Forms.Button btnCancel;
}
}

View File

@@ -0,0 +1,753 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
using System.Text.RegularExpressions;
using System.IO;
using System.Security.AccessControl;
using System.Management;
using System.Security.Principal;
using System.Runtime.InteropServices;
using Microsoft.Win32;
using CommonLib.Windows.Forms;
using CommonLib.IO;
using CommonLib.Misc;
using CommonLib.Windows.Misc;
namespace All_Purpose_Auto_Setup
{
public partial class frmSetupStatusDisplay : ChildForm
{
enum SectionName { Setup_Step_Manager };
private delegate bool SetupStepDelegate(string iniSectionName);
private delegate string CustomMessageBoxDelegate(MessageBoxCustom.PopUpMsgType msgType, List<MessageBoxCustom.clsCustomButton> customButtons, string msg, string caption, int timeOut_ms);
private AutoResetEvent _resetEvent = new AutoResetEvent(false);
private frmMain frmParent = null;
public bool restartApplicationRequested = false;
public bool rebootRequested = false;
public bool setupProcessNeedRestartToContinue = false;
BackgroundWorker bgwSetup;
string pathAndNameOfConfigFile = "";
string pathAndNameOfSetupLog = @"setupLog.txt";
StreamWriter swSetupLog;
ConfigFileManager configFileMgr;
WindowFeaturesManager windowFeaturesMgr;
DotNet2Pt0FrameworkManager dotNet2Pt0FrameworkMgr;
FoldersManager gutsFoldersMgr;
WindowsShortcutManager winShortcutMgr;
SetupMiscellaneous gutsSetupMisc;
SoftwareInstallManager softwareInstallMgr;
GutsSoftwareBuildAssistant gutsBuildAssistant;
FilePackageTransferManager fileTransferManager;
GutsConfigFileManager gutsConfigFileManager;
FileFolderRemovalManager fileSystemRemovalManager;
RunApplicationsManager runAppManager;
WindowsRegistryManager winRegistryManager;
NetworkAdapterManager networkCardManager;
Dictionary<int, bool> richTextBoxLineNumberDict = new Dictionary<int, bool>();
List<ConfigFileManager.Ini_KeyValue<string>> configInfo = new List<ConfigFileManager.Ini_KeyValue<string>>();
List<string[]> configInfoFormatted = new List<string[]>();
public frmSetupStatusDisplay(frmMain d_parentForm)
{
InitializeComponent();
this.frmParent = d_parentForm;
this.FormClosing += Form_FormClosing;
statusRtxtbox.WordWrap = false;
}
void Form_FormClosing(object sender, FormClosingEventArgs e)
{
if (swSetupLog != null)
swSetupLog.Close();
}
private void frmSetupStatusDisplay_Shown(object sender, EventArgs e)
{
swSetupLog = null;
pathAndNameOfConfigFile = frmParent.getConfigFile();
// process the configuration file
configFileMgr = new ConfigFileManager(this, pathAndNameOfConfigFile);
pathAndNameOfSetupLog = Path.Combine(Application.StartupPath,pathAndNameOfSetupLog);
pathAndNameOfSetupLog = FileManip.GenerateUniqueFileName(Path.GetDirectoryName(pathAndNameOfSetupLog),
Path.GetFileNameWithoutExtension(pathAndNameOfSetupLog), Path.GetExtension(pathAndNameOfSetupLog));
try
{
swSetupLog = new StreamWriter(pathAndNameOfSetupLog);
}
catch (Exception)
{
try
{
pathAndNameOfSetupLog = PathManip.AddTrailingSlashToPath(PathManip.GetUserDesktopPath()) + Path.GetFileName(pathAndNameOfSetupLog);
swSetupLog = new StreamWriter(pathAndNameOfSetupLog);
}
catch (Exception)
{
}
}
bgwSetup = new BackgroundWorker();
bgwSetup.WorkerSupportsCancellation = true;
bgwSetup.DoWork += new DoWorkEventHandler(bgwSetup_DoWork);
bgwSetup.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bgwSetup_RunWorkerCompleted);
bgwSetup.RunWorkerAsync();
}
private void restartApplicationEventHandler()
{
restartApplicationRequested = true;
}
private void rebootComputerEventHandler()
{
rebootRequested = true;
}
private void setupProcessNeedRestartToContinueEventHandler()
{
setupProcessNeedRestartToContinue = true;
}
private void updateStatusDisplayAndLogEventHandler(string displayMsg, string logMsg, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList)
{
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
defaultTextProp.textFont = new Font(defaultTextProp.textFont.Name, 9);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, displayMsg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
if (swSetupLog != null && logMsg.Length > 0)
{
string str = Regex.Replace(logMsg, @"\r", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\n", "\r\n", RegexOptions.IgnoreCase);
swSetupLog.Write(str);
}
}
public int updateStatusDisplayAndLog(string displayMsg, string logMsg, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList)
{
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
defaultTextProp.textFont = new Font(defaultTextProp.textFont.Name, 9);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, displayMsg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
if (swSetupLog != null && logMsg.Length > 0)
{
string str = Regex.Replace(logMsg, @"\r", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\n", "\r\n", RegexOptions.IgnoreCase);
swSetupLog.Write(str);
}
return FormControlsManipThreadSafe.getRichTextBoxLastLineIndex(statusRtxtbox);
}
public void writeToLog(string logMsg)
{
if (swSetupLog != null && logMsg.Length > 0)
{
string str = Regex.Replace(logMsg, @"\r", "", RegexOptions.IgnoreCase);
str = Regex.Replace(str, @"\n", "\r\n", RegexOptions.IgnoreCase);
swSetupLog.Write(str);
}
}
public void removeStatusDisplayLine(int lineIndex, bool deleteLine)
{
FormControlsManipThreadSafe.RichTextBoxEraseLine(statusRtxtbox, lineIndex, deleteLine);
}
private void updateStatusDisplayAtLineEventHandler(string displayMsg, int lineIndex, List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList)
{
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
defaultTextProp.textFont = new Font(defaultTextProp.textFont.Name, 9);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWordsAtLine(statusRtxtbox, lineIndex, displayMsg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
}
public string displayMessageBox(MessageBoxCustom.PopUpMsgType msgType, List<MessageBoxCustom.clsCustomButton> customButtons, string msg, string caption, int timeOut_ms)
{
if (InvokeRequired)
{
CustomMessageBoxDelegate del = new CustomMessageBoxDelegate(displayMessageBox);
return (string)this.Invoke(del, msgType, customButtons, msg, caption, timeOut_ms);
}
else
{
return MessageBoxCustom.Show(this, msgType, customButtons, msg, caption, timeOut_ms);
}
}
private void bgwSetup_DoWork(object sender, DoWorkEventArgs bgwEvent)
{
string msg = "", errMsg = "";
bool setupSuccessful = false;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
BackgroundWorker bgw = sender as BackgroundWorker;
setupSuccessful = displayAndLogHeaderInfo();
ConfigFileManager.parseConfigInfo(SectionName.Setup_Step_Manager.ToString(), configInfo);
if (setupSuccessful)
setupSuccessful = verifySetupStepsInfo();
//if (setupSuccessful)
// setupSuccessful = configFileMgr.verifyConfigurationInfo();
int currentSetupStep = 0;
if (setupSuccessful)
{
// manages windows features
windowFeaturesMgr = new WindowFeaturesManager(this);
// add an event handler to an event raised by windowFeaturesMgr
windowFeaturesMgr.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
windowFeaturesMgr.UpdateStatusDisplayAtLine += updateStatusDisplayAtLineEventHandler;
// manages .NET Framework 2.0 Settings
dotNet2Pt0FrameworkMgr = new DotNet2Pt0FrameworkManager(this);
// add an event handler to an event raised by dotNet2Pt0FrameworkMgr
dotNet2Pt0FrameworkMgr.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
// manages file package transfer
fileTransferManager = new FilePackageTransferManager(this);
// add an event handler to an event raised by FilePackageTransferManager
fileTransferManager.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
fileTransferManager.UpdateStatusDisplayAtLine += updateStatusDisplayAtLineEventHandler;
// manages removal of files and folders
fileSystemRemovalManager = new FileFolderRemovalManager(this);
// add an event handler to an event raised by FileFolderRemovalManager
fileSystemRemovalManager.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
fileSystemRemovalManager.UpdateStatusDisplayAtLine += updateStatusDisplayAtLineEventHandler;
// manages folders
gutsFoldersMgr = new FoldersManager(this);
// add an event handler to an event raised by gutsFoldersMgr
gutsFoldersMgr.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
// manages windows shortcut
winShortcutMgr = new WindowsShortcutManager(this);
// add an event handler to an event raised by WindowsShortcutManager
winShortcutMgr.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
// process GUTS config file
gutsConfigFileManager = new GutsConfigFileManager(this);
// add an event handler to an event raised by GutsConfigFileManager
gutsConfigFileManager.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
// setup miscellaneous items
gutsSetupMisc = new SetupMiscellaneous(this);
// add an event handler to an event raised by SetupMiscellaneous
gutsSetupMisc.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
// manages software installs
softwareInstallMgr = new SoftwareInstallManager(this);
// add an event handler to an event raised by softwareInstallMgr
softwareInstallMgr.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
softwareInstallMgr.UpdateStatusDisplayAtLine += updateStatusDisplayAtLineEventHandler;
softwareInstallMgr.RebootComputer += rebootComputerEventHandler;
softwareInstallMgr.SetupProcessNeedRestartToProceed += setupProcessNeedRestartToContinueEventHandler;
// manages running applications
runAppManager = new RunApplicationsManager(this);
// add an event handler to an event raised by RunApplicationsManager
runAppManager.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
runAppManager.UpdateStatusDisplayAtLine += updateStatusDisplayAtLineEventHandler;
// assist in building GUTS
gutsBuildAssistant = new GutsSoftwareBuildAssistant(this);
// add an event handler to an event raised by GutsSoftwareBuildAssistant
gutsBuildAssistant.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
gutsBuildAssistant.RestartApplication += restartApplicationEventHandler;
winRegistryManager = new WindowsRegistryManager(this);
winRegistryManager.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
networkCardManager = new NetworkAdapterManager(this);
networkCardManager.UpdateStatusDisplayAndLogEvent += updateStatusDisplayAndLogEventHandler;
Dictionary<Common.enum_SETUP_STEPS, SetupStepDelegate> setupStepCalls = new Dictionary<Common.enum_SETUP_STEPS, SetupStepDelegate>()
{ { Common.enum_SETUP_STEPS.ASSIST_BUILDING_GUTS_APP, gutsBuildAssistant.gutsPrebuildCheck},
{ Common.enum_SETUP_STEPS.CREATE_DIRECTORIES, gutsFoldersMgr.createDirectories},
{ Common.enum_SETUP_STEPS.CREATE_WINDOWS_SHORTCUTS, winShortcutMgr.creatShortcuts},
{ Common.enum_SETUP_STEPS.CREATE_NETWORK_SHARES, gutsFoldersMgr.shareFolders},
{ Common.enum_SETUP_STEPS.ENABLE_INTERNET_INFORMATION_SERVICES, windowFeaturesMgr.enableWindowsOptionalFeatures},
{ Common.enum_SETUP_STEPS.INSTALL_SOFTWARE_PACKAGES, softwareInstallMgr.manageRequiredSoftwarePackages},
{ Common.enum_SETUP_STEPS.PROCESS_GUTS_CONFIG_FILE, gutsConfigFileManager.processGutsConfigFile},
{ Common.enum_SETUP_STEPS.SET_DOTNET_FRAMEWORK_2_SECURITY_ZONE_LEVELS, dotNet2Pt0FrameworkMgr.adjustZoneSecurityForDotNetFrameWork2Pt0},
{ Common.enum_SETUP_STEPS.SET_ENVIRONMENT_VARIABLES, gutsSetupMisc.setEnvironmentVariables},
{ Common.enum_SETUP_STEPS.TRANSFER_FILE_PACKAGES, fileTransferManager.manageFilePackageTransfer},
{ Common.enum_SETUP_STEPS.REMOVE_FILES_FOLDERS, fileSystemRemovalManager.removeFilesFolders},
{ Common.enum_SETUP_STEPS.RUN_APPLICATIONS, runAppManager.runApplications},
{ Common.enum_SETUP_STEPS.MODIFY_WINDOWS_REGISTRY, winRegistryManager.ModifyWindowsRegistry},
{ Common.enum_SETUP_STEPS.CONFIGURE_NETWORK_ADAPTERS, networkCardManager.configureNetworkAdapters},
{ Common.enum_SETUP_STEPS.PROMPT_USER, gutsSetupMisc.promptUser},
};
foreach (string[] entry in configInfoFormatted)
{
currentSetupStep++;
Common.enum_SETUP_STEPS actualSetupstep = Common.enum_SETUP_STEPS.NOT_VALID_STEP;
// the application had to be restart or rebooted in the middle of execution, we want to continue
// at the point where it left off
if ((int)Properties.Settings.Default["CurrentSetupStep"] > 0 &&
currentSetupStep < (int)Properties.Settings.Default["CurrentSetupStep"])
continue;
if ( getActualSetupStep(entry[0], ref actualSetupstep) )
{
setupSuccessful = setupStepCalls[actualSetupstep].Invoke(entry[1]);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = "\n<-------------------Date and Time: " + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture) + "------------------->";
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
}
if (!setupSuccessful || applicationNeedsToBeRestarted())
break;
}
}
// only genereate summary if the entire setup process is complete or if an actual failure occur
if (!applicationNeedsToBeRestarted())
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = 0;
textProp.wordCount = 3;
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n\nOVERALL SETUP STATUS: ";
if (!setupSuccessful)
{
msg += " - FAILED.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.FAILURE);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "FAILED.");
textProp.wordCount = 10;
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
Properties.Settings.Default["CurrentSetupStep"] = currentSetupStep;
}
else
{
msg += " - SUCCESS.";
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.wordIndex = StringManip.GetPhraseWordIndexInText(msg, "SUCCESS.");
textProp.wordCount = 10;
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
Properties.Settings.Default["CurrentSetupStep"] = -1;
string registryPath = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon";
// disable windows auto login
WindowsRegistry.AddOrModifyRegistryKeySingleValue(registryPath, Microsoft.Win32.RegistryHive.LocalMachine, "AutoAdminLogon", Microsoft.Win32.RegistryValueKind.String, "0", ref errMsg);
// delete user password
WindowsRegistry.DeleteRegistryValueName(registryPath, Microsoft.Win32.RegistryHive.LocalMachine, "DefaultPassword", ref errMsg);
}
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
msg = Regex.Replace(msg, @"\r", "", RegexOptions.IgnoreCase);
msg = Regex.Replace(msg, @"\n", "\r\n", RegexOptions.IgnoreCase);
swSetupLog.Write(msg);
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = 0;
textProp.wordCount = 3;
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\nSETUP COMPLETED.";
FormControlsManipThreadSafe.ModifyControlText(btnCancel, "CLOSE");
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
msg = Regex.Replace(msg, @"\r", "", RegexOptions.IgnoreCase);
msg = Regex.Replace(msg, @"\n", "\r\n", RegexOptions.IgnoreCase);
swSetupLog.Write(msg);
DateTime dat1 = DateTime.Now;
msg = StringManip.TextAlign("\nDate and Time: ", 25, StringManip.enumTextHorizontalAlignment.Left) + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
}
else
{
if (restartApplicationRequested)
{
if (setupSuccessful)
{
if (!ConfigFileManager.ms_configGlobalSettings.suppressAllPrompts.alternateValue)
displayMessageBox(MessageBoxCustom.PopUpMsgType.INFO, null, "The application needs to be restarted.\n\n.Press OK to restart the application now.", "Info", -1);
}
else
restartApplicationRequested = false;
}
Properties.Settings.Default["CurrentSetupStep"] = currentSetupStep;
}
if (rebootRequested)
{
if (setupSuccessful)
{
if (!ConfigFileManager.ms_configGlobalSettings.suppressAllPrompts.alternateValue)
{
msg = displayMessageBox(MessageBoxCustom.PopUpMsgType.YESNO, null, "Reboot is required for the previous changes to take effect.\n\nWould you like reboot now?", "Info", -1);
if (String.Equals(msg, "no", StringComparison.OrdinalIgnoreCase))
{
rebootRequested = false;
}
}
}
else
rebootRequested = false;
}
}
private void bgwSetup_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// if an exception is thrown
if (e.Error != null)
{
}
else
{
swSetupLog.Close();
if (restartApplicationRequested || rebootRequested)
{
this.Close();
}
}
}
private bool getActualSetupStep(string strSetupStep, ref Common.enum_SETUP_STEPS enumSetupStep)
{
bool successful = false;
enumSetupStep = Common.enum_SETUP_STEPS.NOT_VALID_STEP;
foreach (Common.enum_SETUP_STEPS enumStep in Enum.GetValues(typeof(Common.enum_SETUP_STEPS)))
{
if (String.Equals(strSetupStep, enumStep.ToString(), StringComparison.OrdinalIgnoreCase))
{
successful = true;
enumSetupStep = enumStep;
}
}
return successful;
}
public bool applicationNeedsToBeRestarted()
{
bool restart = false;
if (restartApplicationRequested || setupProcessNeedRestartToContinue)
restart = true;
return restart;
}
private bool verifySetupStepsInfo()
{
bool setupSuccessful = true;
string msg;
ConfigFileManager.Ini_KeyValue<string> iniVal = new ConfigFileManager.Ini_KeyValue<string>("");
string indentation = String.Empty;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = Common.getSetupStepTitleColor();
textProp.wordIndex = 0;
textProp.wordCount = 10;
// set font size
textProp.textFont = new Font(textProp.textFont.Name, 12);
// set font style
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
msg = "\n\n-=Verifying setup step information=-";
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
if (configInfo.Count == 0)
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Error Description: The section " + SectionName.Setup_Step_Manager + " doesn't exist or have no entries.";
Common.formatConfigIniFailureMessage(msg, textPropList);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
swSetupLog.Write(msg);
setupSuccessful = false;
}
if (setupSuccessful)
{
foreach (ConfigFileManager.Ini_KeyValue<string> entry in configInfo)
{
List<string> pair = new List<string>(entry.iniValue.Split(new string[] { "," }, StringSplitOptions.None));
if (pair.Count <= 2)
{
pair[0] = pair[0].Trim();
if (pair.Count == 1)
pair.Add("");
pair[1] = pair[1].Trim();
Common.enum_SETUP_STEPS actualSetupstep = Common.enum_SETUP_STEPS.NOT_VALID_STEP;
if (getActualSetupStep(pair[0], ref actualSetupstep))
{
configInfoFormatted.Add(new string[2] { pair[0], pair[1] });
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.iniSectionName
+ "\n" + indentation + "Key: " + entry.iniKeyName
+ "\n" + indentation + "Value: " + entry.iniValue
+ "\n" + indentation + "Error Description: The setup step \"" + pair[0] + "\" specified in the value above is invalid";
Common.formatConfigIniFailureMessage(msg, textPropList);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
setupSuccessful = false;
break;
}
}
else
{
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- FAILED. "
+ "\n" + indentation + "File: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile
+ "\n" + indentation + "Section: " + entry.iniSectionName
+ "\n" + indentation + "Key: " + entry.iniKeyName
+ "\n" + indentation + "Value: " + entry.iniValue
+ "\n" + indentation + "Error Description: The value is invalid the INI file. Expecting install step and associated section name separated by comma";
Common.formatConfigIniFailureMessage(msg, textPropList);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
setupSuccessful = false;
break;
}
}
}
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = 0;
textProp.wordCount = 3;
textProp.textColor = Common.getSetupStatusColor(Common.EXECUTION_STATUS.SUCCESS);
textProp.textFont = new Font(textProp.textFont, FontStyle.Bold);
textPropList.Add(textProp);
indentation = Common.getIndentation(1);
msg = "\n" + indentation + "- SUCCESS.";
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
}
return setupSuccessful;
}
private bool displayAndLogHeaderInfo()
{
bool setupSuccessful = true;
CommonLib.Windows.Forms.TextFormat.TextFontAndColor defaultTextProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
defaultTextProp.textFont = new Font(defaultTextProp.textFont.Name, 9);
CommonLib.Windows.Forms.TextFormat.TextFontAndColor textProp = new CommonLib.Windows.Forms.TextFormat.TextFontAndColor("");
List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor> textPropList = new List<CommonLib.Windows.Forms.TextFormat.TextFontAndColor>();
string msg;
if (ConfigFileManager.ms_configGeneralInfo.programName.iniValue.Length > 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = 0;
textProp.wordCount = 10;
textProp.textColor = Color.BlueViolet;
textProp.textFont = new Font("Tahoma", 17, FontStyle.Bold | FontStyle.Underline);
textPropList.Add(textProp);
msg = ConfigFileManager.ms_configGeneralInfo.programName.iniValue;
}
else
{
msg = "\n\nFAILURE ENCOUNTERED: "
+ "\nFile: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile + " "
+ "\nSection: " + ConfigFileManager.ms_configGeneralInfo.programName.iniSectionName + " "
+ "\nKey: " + ConfigFileManager.ms_configGeneralInfo.programName.iniKeyName + " "
+ "\nValue: " + ConfigFileManager.ms_configGeneralInfo.programName.iniValue + " "
+ "\nError Description: Either one or a combination of Section, Key, or Value is not defined in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
setupSuccessful = false;
}
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
if (setupSuccessful)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = 0;
textProp.wordCount = 3;
textProp.textColor = Color.Brown;
textProp.textFont = new Font("Courier New", 10, FontStyle.Regular);
textPropList.Add(textProp);
textProp.textColor = Color.Black;
textProp.wordIndex = 3;
textProp.wordCount = 100;
textPropList.Add(textProp);
DateTime dat1 = DateTime.Now;
msg = StringManip.TextAlign("\nDate and Time: ", 25, StringManip.enumTextHorizontalAlignment.Left) + dat1.ToString(@"MM/dd/yyyy hh:mm:ss tt", System.Globalization.CultureInfo.InvariantCulture);
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
}
if (setupSuccessful)
{
if (ConfigFileManager.ms_configGeneralInfo.applicationPlatform.iniValue.Length > 0)
{
// set font to default text and color
textProp.textFont = defaultTextProp.textFont;
textProp.textColor = defaultTextProp.textColor;
textProp.wordIndex = 0;
textProp.wordCount = 2;
textProp.textColor = Color.Brown;
textProp.textFont = new Font("Courier New", 10, FontStyle.Regular);
textPropList.Add(textProp);
textProp.textColor = Color.Black;
textProp.wordIndex = 2;
textProp.wordCount = 100;
textPropList.Add(textProp);
msg = StringManip.TextAlign("\nApplication Platform: ", 25, StringManip.enumTextHorizontalAlignment.Left) + ConfigFileManager.ms_configGeneralInfo.applicationPlatform.iniValue + "-Bit";
}
else
{
msg = "\n\nFAILURE ENCOUNTERED: "
+ "\nFile: " + ConfigFileManager.ms_configGeneralInfo.pathAndNameOfConfigFile + " "
+ "\nSection: " + ConfigFileManager.ms_configGeneralInfo.applicationPlatform.iniSectionName + " "
+ "\nKey: " + ConfigFileManager.ms_configGeneralInfo.applicationPlatform.iniKeyName + " "
+ "\nValue: " + ConfigFileManager.ms_configGeneralInfo.applicationPlatform.iniValue + " "
+ "\nError Description: Either one or a combination of Section, Key, or Value is not defined in the INI file.";
Common.formatConfigIniFailureMessage(msg, textPropList);
setupSuccessful = false;
}
FormControlsManipThreadSafe.ModifyRichTextBoxPerWords(statusRtxtbox, msg, textPropList, defaultTextProp.textFont, defaultTextProp.textColor);
writeToLog(msg);
}
return setupSuccessful;
}
private void btnCancel_Click(object sender, EventArgs e)
{
if (String.Equals(btnCancel.Text, "close", StringComparison.OrdinalIgnoreCase))
{
this.Close();
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
namespace All_Purpose_Auto_Setup
{
partial class frmUserInput
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.txtBoxPassword = new System.Windows.Forms.TextBox();
this.btnOK = new System.Windows.Forms.Button();
this.rTxtBoxDescription = new System.Windows.Forms.RichTextBox();
this.SuspendLayout();
//
// txtBoxPassword
//
this.txtBoxPassword.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtBoxPassword.Location = new System.Drawing.Point(90, 86);
this.txtBoxPassword.Name = "txtBoxPassword";
this.txtBoxPassword.PasswordChar = '*';
this.txtBoxPassword.Size = new System.Drawing.Size(244, 26);
this.txtBoxPassword.TabIndex = 0;
this.txtBoxPassword.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtBoxPassword_KeyDown);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(161, 117);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(95, 32);
this.btnOK.TabIndex = 1;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// rTxtBoxDescription
//
this.rTxtBoxDescription.BackColor = System.Drawing.SystemColors.Menu;
this.rTxtBoxDescription.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.rTxtBoxDescription.Location = new System.Drawing.Point(21, 8);
this.rTxtBoxDescription.Name = "rTxtBoxDescription";
this.rTxtBoxDescription.Size = new System.Drawing.Size(359, 67);
this.rTxtBoxDescription.TabIndex = 2;
this.rTxtBoxDescription.Text = "";
//
// frmUserInput
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(397, 158);
this.ControlBox = false;
this.Controls.Add(this.rTxtBoxDescription);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.txtBoxPassword);
this.Name = "frmUserInput";
this.Text = "User Input";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox txtBoxPassword;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.RichTextBox rTxtBoxDescription;
}
}

View File

@@ -0,0 +1,65 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using CommonLib.Windows.Forms;
namespace All_Purpose_Auto_Setup
{
public partial class frmUserInput : ChildForm
{
private frmMain frmParent = null;
public frmUserInput(frmMain d_parentForm)
{
InitializeComponent();
frmParent = d_parentForm;
}
public string getUserPassword()
{
return txtBoxPassword.Text;
}
public void clearUserPassword()
{
txtBoxPassword.Clear();
}
public void richTxtBoxAppendText(string description)
{
rTxtBoxDescription.AppendText(description);
}
public void richTxtBoxOverwriteText(string description)
{
rTxtBoxDescription.Clear();
rTxtBoxDescription.AppendText("ddd");
rTxtBoxDescription.Clear();
rTxtBoxDescription.AppendText(description);
}
private void btnOK_Click(object sender, EventArgs e)
{
txtBoxPassword.Focus();
this.Hide();
}
private void txtBoxPassword_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
btnOK_Click(this, new EventArgs());
}
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="TaskScheduler" version="2.5.28" targetFramework="net45" requireReinstallation="true" />
</packages>

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB