Skip to content

Instantly share code, notes, and snippets.

@hereisderek
Last active December 30, 2025 13:39
Show Gist options
  • Select an option

  • Save hereisderek/ab09258af0d67b2be1dfd9572cd8fa3f to your computer and use it in GitHub Desktop.

Select an option

Save hereisderek/ab09258af0d67b2be1dfd9572cd8fa3f to your computer and use it in GitHub Desktop.
This PowerShell script is designed to automate the maintenance of Vencord
# ============================================
# Discord + Vencord Launcher (Universal)
# ============================================
#
# execute the following in powershell:
# iex (iwr "https://gist.githubusercontent.com/hereisderek/ab09258af0d67b2be1dfd9572cd8fa3f/raw/DiscordWithVencord.ps1" -UseBasicParsing).Content
# or in run:
# powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -Command "iwr 'https://gist.githubusercontent.com/hereisderek/ab09258af0d67b2be1dfd9572cd8fa3f/raw/DiscordWithVencord.ps1' -UseBasicParsing | iex"
$ErrorActionPreference = "SilentlyContinue"
# ---- ENVIRONMENT DETECTION ----
$Invocation = $MyInvocation.MyCommand.Definition
# Check if the invocation is a local file path (exists on disk)
if ($Invocation -and (Test-Path $Invocation -PathType Leaf)) {
# LOCAL MODE: Use the folder where the .ps1 file is stored
$BaseDir = Split-Path -Parent $Invocation
$Mode = "Local"
} else {
# PIPELINE/IEX MODE: Use a persistent folder in LocalAppData
$BaseDir = Join-Path $env:LOCALAPPDATA "VencordLauncher"
$Mode = "Web/Pipeline"
}
# ---- DIRECTORY SETUP ----
# Ensure the folder exists immediately so we don't get 'Path is null' errors
if (!(Test-Path $BaseDir)) {
New-Item -ItemType Directory -Path $BaseDir -Force | Out-Null
}
$CacheDir = Join-Path $BaseDir "VencordCache"
$StampFile = Join-Path $BaseDir "vencord_last_update.txt"
$LogFile = Join-Path $BaseDir "vencord_launcher.log"
if (!(Test-Path $CacheDir)) { New-Item -ItemType Directory -Path $CacheDir -Force | Out-Null }
function Write-Log($Message) {
$Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
$LogEntry = "[$Timestamp] $Message"
Write-Host $LogEntry
try { Add-Content -Path $LogFile -Value $LogEntry } catch {}
}
Write-Log "--- Script Started ($Mode Mode) ---"
Write-Log "Storage Path: $BaseDir"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# ---- FIND DISCORD ----
$DiscordRoots = @("$env:LOCALAPPDATA\Discord", "$env:LOCALAPPDATA\DiscordPTB", "$env:LOCALAPPDATA\DiscordCanary")
$DiscordPath = $null
$DiscordUpdateExe = $null
foreach ($root in $DiscordRoots) {
if (Test-Path "$root\Update.exe") {
$DiscordUpdateExe = "$root\Update.exe"
$app = Get-ChildItem $root -Directory -Filter "app-*" | Sort-Object Name -Descending | Select-Object -First 1
if ($app) {
$DiscordPath = $app.FullName
Write-Log "Discord Found: $DiscordPath"
break
}
}
}
if (-not $DiscordUpdateExe) {
Write-Log "CRITICAL: Discord not found. Exiting."
exit
}
# ---- UPDATE LOGIC ----
$Today = Get-Date -Format "yyyy-MM-dd"
$LastRun = if (Test-Path $StampFile) { Get-Content $StampFile } else { "" }
if ($LastRun -ne $Today) {
Write-Log "Checking for Vencord updates..."
try {
$release = Invoke-RestMethod "https://api.github.com/repos/Vencord/Installer/releases/latest"
$LatestVersion = $release.tag_name
$TargetFileName = "VencordInstallerCli-$LatestVersion.exe"
$LocalInstallerPath = Join-Path $CacheDir $TargetFileName
if (!(Test-Path $LocalInstallerPath)) {
Write-Log "New version detected: $LatestVersion."
$asset = $release.assets | Where-Object { $_.name -match "VencordInstallerCli.*\.exe" } | Select-Object -First 1
if ($asset) {
# Clean old cached installers
Get-ChildItem -Path $CacheDir -Filter "VencordInstallerCli-*.exe" | Remove-Item -Force
Invoke-WebRequest $asset.browser_download_url -OutFile $LocalInstallerPath -UseBasicParsing
Write-Log "Download complete: $TargetFileName"
Write-Log "Ensuring Discord is closed for patching..."
Stop-Process -Name "Discord", "DiscordCanary", "DiscordPTB" -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 2
Write-Log "Executing installer (Hidden)..."
$proc = Start-Process -FilePath $LocalInstallerPath -ArgumentList "-install", "-location", "`"$DiscordPath`"" -WindowStyle Hidden -PassThru
# Wait up to 30 seconds for completion
$timeout = 30; $timer = 0
while (!$proc.HasExited -and $timer -lt $timeout) { Start-Sleep -Seconds 1; $timer++ }
if (!$proc.HasExited) { Stop-Process -Id $proc.Id -Force; Write-Log "Installer timed out." }
else { Write-Log "Installer exited successfully." }
}
} else {
Write-Log "Current version ($LatestVersion) matches cache. Skipping install."
}
Set-Content -Path $StampFile -Value $Today
} catch {
Write-Log "Update failed: $($_.Exception.Message)"
}
} else {
Write-Log "Daily update already verified today."
}
# ---- LAUNCH ----
Write-Log "Starting Discord..."
Start-Process -FilePath $DiscordUpdateExe -ArgumentList "--processStart Discord.exe" -WindowStyle Hidden
Write-Log "--- Script Finished ---"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment