diff --git a/App.config b/App.config
index e1412c9..5b2bbca 100644
--- a/App.config
+++ b/App.config
@@ -39,6 +39,9 @@
C:\HAC\scripts\
+
+ C:\Program Files\XRFAgent\tools\
+
\ No newline at end of file
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index 33b9fbf..8c4fe73 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.10")]
-[assembly: AssemblyFileVersion("1.0.0.10")]
+[assembly: AssemblyVersion("1.0.0.11")]
+[assembly: AssemblyFileVersion("1.0.0.11")]
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 4b808ad..3167e39 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace XRFAgent.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.10.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -49,5 +49,14 @@ public string Scripts_FolderURI {
return ((string)(this["Scripts_FolderURI"]));
}
}
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("C:\\Program Files\\XRFAgent\\tools\\")]
+ public string Tools_FolderURI {
+ get {
+ return ((string)(this["Tools_FolderURI"]));
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 6758f03..328706e 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -11,5 +11,8 @@
C:\HAC\scripts\
+
+ C:\Program Files\XRFAgent\tools\
+
\ No newline at end of file
diff --git a/XRFAgent.csproj b/XRFAgent.csproj
index 20336ad..d43cf43 100644
--- a/XRFAgent.csproj
+++ b/XRFAgent.csproj
@@ -25,7 +25,7 @@
false
false
true
- 10
+ 11
1.0.0.%2a
false
true
diff --git a/docs/ErrorCodes.md b/docs/ErrorCodes.md
index 254fbfe..7a51e25 100644
--- a/docs/ErrorCodes.md
+++ b/docs/ErrorCodes.md
@@ -9,9 +9,13 @@
6021 - Update check failed
6022 - Update failed
6023 - Update starting (informational)
+6024 - Tool installation failed
6031 - External process start error
6032 - Registry access error
+6041 - Windows Update error
+6042 - Windows Update results (informational)
+
6051 - Detected new software installed (informational)
6052 - Truncated installed software inventory (informational)
\ No newline at end of file
diff --git a/modCommand.cs b/modCommand.cs
index 77ed628..c283eac 100644
--- a/modCommand.cs
+++ b/modCommand.cs
@@ -63,6 +63,21 @@ public static void Handle(string inputCommand, string inputSource, string reques
outputResponse = "Updating"; break;
}
break;
+ case "windows":
+ result = modSystem.InstallWindowsUpdates();
+ switch (result)
+ {
+ case 0:
+ outputResponse = "Update successful"; break;
+ case -1:
+ case 31:
+ outputResponse = "Update error"; break;
+ case 3010:
+ outputResponse = "Reboot required"; break;
+ default:
+ outputResponse = "Updating"; break;
+ }
+ break;
default: break;
}
break;
diff --git a/modSystem.cs b/modSystem.cs
index e05b55a..0074cad 100644
--- a/modSystem.cs
+++ b/modSystem.cs
@@ -181,6 +181,35 @@ public static string GetSystemDetails()
}
}
+ public static int InstallWindowsUpdates()
+ {
+ try
+ {
+ if (File.Exists(Properties.Settings.Default.Tools_FolderURI + "WindowsUpdatePush.exe") == false)
+ {
+ int installResult = modUpdate.InstallWindowsUpdatePush();
+ if (installResult == -1)
+ {
+ return -1;
+ }
+ }
+ Process UpdateRunner = new Process();
+ UpdateRunner.StartInfo.UseShellExecute = false;
+ UpdateRunner.StartInfo.RedirectStandardOutput = true;
+ UpdateRunner.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
+ UpdateRunner.StartInfo.FileName = Properties.Settings.Default.Tools_FolderURI + "WindowsUpdatePush.exe";
+ UpdateRunner.Start();
+ UpdateRunner.WaitForExit();
+ modLogging.LogEvent(UpdateRunner.StandardOutput.ReadToEnd(), EventLogEntryType.Information, 6042);
+ return UpdateRunner.ExitCode;
+ }
+ catch(Exception err)
+ {
+ modLogging.LogEvent("Windows Update error: " + err.Message, EventLogEntryType.Error, 6041);
+ return -1;
+ }
+ }
+
///
/// Reboots the host computer
///
diff --git a/modUpdate.cs b/modUpdate.cs
index 87331d9..8097a50 100644
--- a/modUpdate.cs
+++ b/modUpdate.cs
@@ -99,6 +99,23 @@ public static int UpdateAgent()
return updateNeeded;
}
+ public static int InstallWindowsUpdatePush()
+ {
+ try
+ {
+ Directory.CreateDirectory(Properties.Settings.Default.Tools_FolderURI);
+ UpdateDownloadClient.DownloadFile(Properties.Settings.Default.Update_SourceURI + "windowsupdatepush.zip", Properties.Settings.Default.Tools_FolderURI + "windowsupdatepush.zip");
+ ZipFile.ExtractToDirectory(Properties.Settings.Default.Tools_FolderURI + "windowsupdatepush.zip", Properties.Settings.Default.Tools_FolderURI);
+ File.Delete(Properties.Settings.Default.Tools_FolderURI + "windowsupdatepush.zip");
+ return 0;
+ }
+ catch (Exception err)
+ {
+ modLogging.LogEvent(err.Message, EventLogEntryType.Error, 6024);
+ return -1;
+ }
+ }
+
public static int Autoupdate()
{
if (modDatabase.GetConfig("Update_Autoupdate") == "enabled")