Skip to content

Instantly share code, notes, and snippets.

@whiskerz007
Last active August 5, 2018 21:15
Show Gist options
  • Save whiskerz007/82fd5611e849145d169835d32b45b4e1 to your computer and use it in GitHub Desktop.
Save whiskerz007/82fd5611e849145d169835d32b45b4e1 to your computer and use it in GitHub Desktop.
Temporarily change displayName in Minecraft Launcher profile
$MCNewDisplayName = Read-Host -Prompt 'Enter the displayName you want to use with Minecraft'
$MCLauncherPath = "${env:APPDATA}\.minecraft\launcher_profiles.json"
function Out-MCLauncherProfiles ([string]$displayName)
{
$MCProfiles.authenticationDatabase.$MCUser.displayName = $displayName
$MCProfiles | ConvertTo-Json | Out-File $MCLauncherPath -Encoding ascii
}
function Start-MCLauncher
{
Start-Process ${env:ProgramFiles(x86)}\Minecraft\MinecraftLauncher.exe -Wait True
}
Write-Host "`n`nAfter Minecraft Launcher starts and fully authenticates, close it."
Write-Host "Starting Minecraft Launcher for initial authentication..."
Start-MCLauncher
Write-Host "Changing Minecraft displayName to '$MCNewDisplayName'..."
$MCProfiles = (Get-Content -Raw -Path $MCLauncherPath | ConvertFrom-Json)
$MCUser = (Select-Object -InputObject $MCProfiles.authenticationDatabase | Get-Member)[-1].Name
$MCOldDisplayName = Select-Object -InputObject $MCProfiles.authenticationDatabase.$MCUser.displayName
Out-MCLauncherProfiles $MCNewDisplayName
Write-Host "Starting Minecraft Launcher with new displayName..."
Start-MCLauncher
Write-Host "Restoring original Minecraft displayName to '$MCOldDisplayName'..."
Out-MCLauncherProfiles $MCOldDisplayName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment