@@ -196,6 +196,10 @@ public static string GetSystemDetails()
196196 }
197197 }
198198
199+ /// <summary>
200+ /// Installs updates for Windows, installs WindowsUpdatePush tool if it is not present
201+ /// </summary>
202+ /// <returns>(int) Return code</returns>
199203 public static int InstallWindowsUpdates ( )
200204 {
201205 try
@@ -225,6 +229,41 @@ public static int InstallWindowsUpdates()
225229 }
226230 }
227231
232+ /// <summary>
233+ /// Runs Ookla Speedtest, installs Speedtest CLI tool if it is not present
234+ /// </summary>
235+ /// <returns></returns>
236+ public static int RunSpeedTest ( )
237+ {
238+ try
239+ {
240+ if ( File . Exists ( Properties . Settings . Default . Tools_FolderURI + "speedtest.exe" ) == false )
241+ {
242+ int installResult = modUpdate . InstallOoklaSpeedtest ( ) ;
243+ if ( installResult == - 1 )
244+ {
245+ return - 1 ;
246+ }
247+ }
248+ Process SpeedTestRunner = new Process ( ) ;
249+ SpeedTestRunner . StartInfo . UseShellExecute = false ;
250+ SpeedTestRunner . StartInfo . RedirectStandardOutput = true ;
251+ SpeedTestRunner . StartInfo . WindowStyle = ProcessWindowStyle . Hidden ;
252+ SpeedTestRunner . StartInfo . FileName = Properties . Settings . Default . Tools_FolderURI + "speedtest.exe" ;
253+ SpeedTestRunner . StartInfo . Arguments = "-f json --accept-license" ;
254+ SpeedTestRunner . Start ( ) ;
255+ SpeedTestRunner . WaitForExit ( ) ;
256+ string speedJson = SpeedTestRunner . StandardOutput . ReadToEnd ( ) ;
257+ modLogging . LogEvent ( "Speed test results: " + speedJson , EventLogEntryType . Information , 6072 ) ;
258+ return SpeedTestRunner . ExitCode ;
259+ }
260+ catch ( Exception err )
261+ {
262+ modLogging . LogEvent ( "Speed test error: " + err . Message , EventLogEntryType . Error , 6071 ) ;
263+ return - 1 ;
264+ }
265+ }
266+
228267 /// <summary>
229268 /// Reboots the host computer
230269 /// </summary>
0 commit comments