Last active
February 3, 2018 22:20
-
-
Save sjadema/7d03a9557a66b25278c3bbc63cb05d01 to your computer and use it in GitHub Desktop.
Powershell script to remove desert map when opening PUBG (and move it back again after closing it). Place both files in the same directory and create a shortcut to the .bat (if needed).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
start powershell -WindowStyle "hidden" -Command "& '.\PUBG.ps1'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Determine Steam base directory and PUBG Steam ID | |
$steamRegistryPath = "HKCU:\Software\Valve\Steam"; | |
$steamAppsDir = (Get-Item $steamRegistryPath).GetValue("SteamPath") + "/steamapps/common/" | |
$pubgSteamAppPath = Get-ChildItem "$($steamRegistryPath)/Apps" -Recurse | Where {$_.GetValue("Name") -eq "PLAYERUNKNOWN'S BATTLEGROUNDS"} | Select-Object -first 1 | |
$pubgSteamAppId = Split-Path $pubgSteamAppPath -Leaf | |
$pubgMapsDirectory = "$($steamAppsDir)/PUBG/TslGame/Content/Paks" | |
# Create temporary folder to move the map files to | |
$tempDirectory = [System.IO.Path]::GetTempFileName() | |
Remove-Item -Path $tempDirectory | |
New-Item -ItemType "directory" -Path $tempDirectory | Out-Null | |
# Move all maps | |
Get-ChildItem -Path $pubgMapsDirectory | Where{$_.Name -Match "desert"} | Move-Item -Destination "$($tempDirectory)" | |
# Launch game | |
Start-Process "steam://rungameid/$($pubgSteamAppId)" | |
# Create watcher to see if the game stopped running | |
$process = $false | |
While ($true) { | |
While (!($process)) { | |
Start-Sleep -s 5 | |
$process = Get-Process "TslGame" -ErrorAction SilentlyContinue | |
} | |
If ($process) { | |
$process.WaitForExit() | |
Start-Sleep -s 2 | |
# Move maps back to original location | |
Get-ChildItem -Path $tempDirectory | Where{$_.Name -Match "desert"} | Move-Item -Destination "$($pubgMapsDirectory)" | |
Remove-Item $tempDirectory | |
Exit | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment