Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save manciuszz/da294675399b0dbef07573e16ce79ed1 to your computer and use it in GitHub Desktop.

Select an option

Save manciuszz/da294675399b0dbef07573e16ce79ed1 to your computer and use it in GitHub Desktop.
Self-executing latest DDU (Display Driver Uninstaller) tool downloading script.
<# :
@echo off
powershell /nologo /noprofile /command "&{[ScriptBlock]::Create((cat """%~f0""") -join [Char[]]10).Invoke(@(&{$args}%*))}"
exit /b
#>
Function Get-LatestDDUVersion {
$pageUrl = 'https://www.wagnardsoft.com/display-driver-uninstaller-DDU-'
Write-Host "Fetching latest DDU versions from $pageUrl..."
try {
$resp = Invoke-WebRequest -Uri $pageUrl -UseBasicParsing -ErrorAction Stop
} catch {
Throw "Failed to retrieve DDU page: $_"
}
$versions = foreach ($link in $resp.Links) {
if ($link.outerHTML -match 'DDU\)\s*(\d+\.\d+\.\d+\.\d+)') {
[string]$Matches[1]
}
}
if (-not $versions) {
Throw "No DDU version strings found in links. The page format may have changed."
}
$latest = $versions | Sort-Object -Descending | Select-Object -First 1
Write-Host "Detected latest DDU version: $latest"
return $latest
}
Function Download-DDU {
param (
[Parameter(Mandatory = $true)]
[string]$Version,
[Parameter(Mandatory = $false)]
[string]$Destination = (Get-Location).Path
)
$fileName = "DDU v$Version.exe"
$escapedName = [uri]::EscapeDataString($fileName)
$downloadUrl = "https://www.wagnardsoft.com/DDU/download/$escapedName"
Write-Host "Downloading DDU version $Version..."
Write-Host "URL: $downloadUrl"
$outFile = Join-Path -Path $Destination -ChildPath $fileName
try {
Invoke-WebRequest -Uri $downloadUrl -OutFile $outFile -UseBasicParsing -ErrorAction Stop
Write-Host "Download completed: $outFile"
} catch {
Throw "Download failed: $_"
}
}
$latestVersion = Get-LatestDDUVersion
Download-DDU -Version $latestVersion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment