Loading...

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

// Step 4: Install the MSI package _logger.LogInfo("Installing USBDK..."); if (!InstallMSI()) _logger.LogError("Failed to install USBDK"); return false;

void LogInfo(string message); void LogError(string message); void LogWarning(string message); void LogSuccess(string message);

# 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 2-download and install usbdk-1.0.22-x64.msi

// Step 2: Check if already installed if (!forceReinstall && IsUSBDKInstalled()) _logger.LogInfo("USBDK is already installed"); return true;

catch Write-Log "ERROR" "Installation error: $($_.Exception.Message)" return $false // Step 4: Install the MSI package _logger

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 ;

// Step 5: Cleanup CleanupInstaller();

if (!File.Exists(_downloadPath)) throw new FileNotFoundException("Downloaded file not found");