Skip to content

Instantly share code, notes, and snippets.

@sin3point14
Created June 22, 2022 22:23
Show Gist options
  • Select an option

  • Save sin3point14/f2ed9d0f064d8ad471c875db5e3d0a1e to your computer and use it in GitHub Desktop.

Select an option

Save sin3point14/f2ed9d0f064d8ad471c875db5e3d0a1e to your computer and use it in GitHub Desktop.
Bypass the WSL EOL check for 31-10-2021 using a small powershell wrapper that changes dates
# TODO: Currently I need to spawn 2 Admin Powershells, they can probably be reduced to 1
$run = wsl -l --running
$run = [string]::join("",($run.Split("`n")))
$running = $false
function Run-Elevated ($scriptblock1, $scriptblock2)
{
# Wait on this powershell instance to finish changing the time
Start-Process -Wait -Verb runas "powershell" -ArgumentList ("-Command `"$scriptblock1`"")
# A non-blocking powershell instance
Start-Process -Verb runas "powershell" -ArgumentList ("-Command `"$scriptblock2`"")
}
$goToPast = @"
Set-Date -Date '23 June 2021 01:39:31' | Out-Null
"@
$restoreDate = @"
Timeout /T 2;
W32tm /resync /force
exit;
"@
# Find if distro is already running
foreach ($element in $run) {
if($element.Split(" ")[0] -eq $args[0])
{
$running = $true
Break
}
}
if (!$running) {
Run-Elevated $goToPast $restoreDate
}
wsl.exe -d $args[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment