2-download - And Install Usbdk-1.0.22-x64.msi

_logger.LogSuccess("USBDK installed successfully!"); return true; catch (Exception ex) _logger.LogError($"Installation failed: ex.Message"); return false;

if ($success) Write-Log "SUCCESS" "USBDK installation completed successfully" exit 0

// Step 5: Cleanup CleanupInstaller();

C# Usage:

public void LogWarning(string message) Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine($"[WARNING] DateTime.Now:HH:mm:ss - message"); Console.ResetColor();

private bool InstallMSI() try // Use msiexec for silent installation string arguments = $"/i \"_downloadPath\" /quiet /norestart"; ProcessStartInfo psi = new ProcessStartInfo FileName = "msiexec.exe", Arguments = arguments, UseShellExecute = false, CreateNoWindow = true, Verb = "runas" // Ensures admin elevation ;

public void LogError(string message) Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"[ERROR] DateTime.Now:HH:mm:ss - message"); Console.ResetColor(); 2-download and install usbdk-1.0.22-x64.msi

catch Write-Log "ERROR" "Installation error: $($_.Exception.Message)" return $false

private void CleanupInstaller() try if (File.Exists(_downloadPath)) File.Delete(_downloadPath); _logger.LogInfo("Cleaned up installer file"); catch (Exception ex) return process.ExitCode == 0; catch (Exception ex) _logger.LogWarning($"Failed to cleanup installer: ex.Message");

class Program

public interface ILogger

# Download and install if (Download-USBDKInstaller) $result = Install-USBDK # Cleanup if (Test-Path $InstallerPath) Remove-Item $InstallerPath -Force -ErrorAction SilentlyContinue Write-Log "INFO" "Cleaned up installer file" return $result