diff --git a/Vrh.Log4Pro.MaintenanceConsole/App.config b/Vrh.Log4Pro.MaintenanceConsole/App.config
index dec5bbc..f250bc3 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/App.config
+++ b/Vrh.Log4Pro.MaintenanceConsole/App.config
@@ -20,11 +20,15 @@
+
+
+
+
-
-
+
+
diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
index 91e91a5..ae07a5c 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
@@ -100,24 +100,39 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS
///
///
///
+ ///
+ ///
///
- public static string ReadLine(string text = null, ConsoleColor? f = null, ConsoleColor? b = null, string bracket = null, string prefix = "",string suffix = "")
+ public static string ReadLine(string text = null, ConsoleColor? f = null, ConsoleColor? b = null, string bracket = null, string prefix = "",string suffix = "",List validitylist=null,string exitvalue="EX",string defaultvalue=null)
{
- if (silentMode)
+ string input;
+ while (true)
{
- if (readlineList == null || readlineList.Length == 0) { return null; }
+ string prompt = text;
+ if (silentMode)
+ {
+ if (readlineList == null || readlineList.Length == 0) { return null; }
+ else
+ {
+ var nextreadline = readlineList[0];
+ readlineList = readlineList.Skip(1).ToArray();
+ return nextreadline;
+ }
+ }
else
{
- var nextreadline = readlineList[0];
- readlineList = readlineList.Skip(1).ToArray();
- return nextreadline;
+ if (validitylist != null && validitylist.Any()) { prompt += $" Valid values are {'\''+string.Join("','", validitylist)+'\''}."; }
+ if (defaultvalue != null) { prompt += $" Default value is '{defaultvalue}'."; }
+ if (exitvalue != null) { prompt += $" Enter EX to exit."; }
+
+ Write(prompt, f, b, bracket, prefix, suffix);
+ input = Console.ReadLine();
+ if (defaultvalue!=null && (input == null || input == "")) { input = defaultvalue; }
+ if (exitvalue != null && input!=null && input.ToLower() == exitvalue || validitylist ==null || !validitylist.Any() || validitylist.Contains(input)) { break; }
+ WriteLine($"Erroneous value!",ConsoleColor.Red);
}
}
- else
- {
- Write(text, f, b, bracket, prefix,suffix);
- return Console.ReadLine();
- }
+ return input;
}
///
diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs
index df3d22b..965dcd2 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs
@@ -17,6 +17,7 @@ using Vrh.XmlProcessing;
using System.Xml.Linq;
using Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS;
using VRH.Common;
+using Microsoft.Win32;
namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS
{
@@ -209,5 +210,27 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS
Process.Start(startinfo);
}
public enum ShutDownMode { Sleep, Hibernation,Lock,Logoff,Restart,ShutDown,}
+ public static string HKLM_GetString(string path, string key)
+ {
+ try
+ {
+ RegistryKey rk = Registry.LocalMachine.OpenSubKey(path);
+ if (rk == null) return "";
+ return (string)rk.GetValue(key);
+ }
+ catch { return ""; }
+ }
+
+ public static string OSFriendlyName()
+ {
+ string ProductName = HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName");
+ string CSDVersion = HKLM_GetString(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CSDVersion");
+ if (ProductName != "")
+ {
+ return (ProductName.StartsWith("Microsoft") ? "" : "Microsoft ") + ProductName +
+ (CSDVersion != "" ? " " + CSDVersion : "");
+ }
+ return "";
+ }
}
}
diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs
index ac04e4a..45da424 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs
@@ -9,7 +9,6 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Web.Administration;
-using System.Management;
using System.Diagnostics;
using Vrh.Log4Pro.MaintenanceConsole.MenuNS;
@@ -22,6 +21,7 @@ using Vrh.Log4Pro.MaintenanceConsole.WebApplicationManagerNS;
using Vrh.XmlProcessing;
using System.Xml.Linq;
using System.Text.RegularExpressions;
+using System.Collections.ObjectModel;
namespace Vrh.Log4Pro.MaintenanceConsole.InstallManagerNS
{
@@ -58,12 +58,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.InstallManagerNS
var config = (parameter as Menu.ExecutorParameter).GetConfig();
InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.Group.Values grp;
InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values os;
- string answer;
- foreach (var wfg in config.WindowsFeatureGroups)
+
+ string osfrn = Tools.OSFriendlyName();
+ var defaultvalue =
+ osfrn.StartsWith("Microsoft Windows 10") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
+ : osfrn.StartsWith("Microsoft Windows Server 2016") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
+ : osfrn.StartsWith("Microsoft Windows Server 2012") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
+ : null;
+ var oslist = Enum.GetNames(typeof(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values)).ToList();
+ string answer = ColorConsole.ReadLine($"Enter os code (friendly name is: '{osfrn}')!", ConsoleColor.Green, validitylist: oslist, defaultvalue: defaultvalue.ToString());
+
+ InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values? selectedos = null;
+ selectedos = (InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values)Enum
+ .Parse(typeof(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values), answer);
+ foreach (var wfg in config.WindowsFeatureGroups.Where(x=>selectedos==null || x.OS== selectedos))
{
grp = wfg.Group;
os = wfg.OS;
- answer = ColorConsole.ReadLine($"Do You want to configure feature group '{grp}' for os '{os}'?(Y/N)", ConsoleColor.Yellow);
+ answer = ColorConsole.ReadLine($"Do You want to configure feature group '{grp}' for os '{os}'?(Y/N)", ConsoleColor.Green);
if (answer.ToUpper() == "Y") { EnableWindowsFeatures(grp, os, config); }
};
return o;
@@ -71,7 +83,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.InstallManagerNS
private static void EnableWindowsFeatures(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.Group.Values grp
, InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values os, InstallManagerXmlParser environmentinstallconfig)
{
- ColorConsole.WriteLine($"Enableing {grp} features for os {os}...",ConsoleColor.Yellow);
+ ColorConsole.WriteLine($"Enableing {grp} features for os {os}...",ConsoleColor.Green);
foreach (var fn in environmentinstallconfig.GetFeatureList(os,grp))
{
if (string.IsNullOrWhiteSpace(fn) || fn.StartsWith("#")) { continue; }
@@ -80,7 +92,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.InstallManagerNS
switch (os)
{
case InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016:
- response = Tools.ExecuteAndGetStdIo("Install-WindowsFeature", $"-Name {fn} -IncludeAllSubFeature -IncludeManagementTools");
+
+ //var cmd = "Powershell -Command {Import-Module ServerManager ; Install-WindowsFeature XXXX}";
+ response = Tools.ExecuteAndGetStdIo("Powershell", $"-Command {{Import - Module ServerManager ; Install-WindowsFeature -Name {fn} -IncludeAllSubFeature -IncludeManagementTools}}");
+ //response = Tools.ExecuteAndGetStdIo("Install-WindowsFeature", $"-Name {fn} -IncludeAllSubFeature -IncludeManagementTools");
break;
case InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.W7:
response = Tools.ExecuteAndGetStdIo("dism", $"/online /Enable-Feature /FeatureName:{fn}");
diff --git a/Vrh.Log4Pro.MaintenanceConsole/Program.cs b/Vrh.Log4Pro.MaintenanceConsole/Program.cs
index 041ef89..1a78914 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Program.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/Program.cs
@@ -134,9 +134,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole
ColorConsole.Write(System.Environment.OSVersion.ServicePack, ConsoleColor.Yellow, bracket: "[]", prefix: "Service pack:", suffix: ",");
ColorConsole.Write(System.Environment.OSVersion.VersionString, ConsoleColor.Yellow, bracket: "[]", prefix: "Version string:");
ColorConsole.WriteLine("");
+ ColorConsole.Write(Tools.OSFriendlyName(), ConsoleColor.Yellow, bracket: "[]", prefix: " Friendly name:");
+ ColorConsole.WriteLine("");
ColorConsole.WriteLine("");
}
}
+
#region MaintenanceConsoleXmlProcessor class
public class MaintenanceConsoleXmlProcessor : XmlParser
{
diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
index 34f824b..3514d43 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.1.0")]
-[assembly: AssemblyFileVersion("1.0.1.0")]
+[assembly: AssemblyVersion("1.1.0.0")]
+[assembly: AssemblyFileVersion("1.1.0.0")]
diff --git a/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj b/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj
index b78c8df..7a9c0a4 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj
+++ b/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj
@@ -215,6 +215,11 @@
..\packages\System.IO.FileSystem.Primitives.4.0.1\lib\net46\System.IO.FileSystem.Primitives.dll
+
+ ..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll
+ True
+ True
+
diff --git a/Vrh.Log4Pro.MaintenanceConsole/packages.config b/Vrh.Log4Pro.MaintenanceConsole/packages.config
index 80ad71a..741a0ad 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/packages.config
+++ b/Vrh.Log4Pro.MaintenanceConsole/packages.config
@@ -39,7 +39,7 @@
-
+
--
libgit2 0.21.2