Last active
August 5, 2018 21:15
-
-
Save whiskerz007/82fd5611e849145d169835d32b45b4e1 to your computer and use it in GitHub Desktop.
Temporarily change displayName in Minecraft Launcher profile
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
1. Save the script as the name is defined. (If you place the script on the desktop, you will not have to change link string.) | |
2. Create a shortcut link and apply the following string (substitute the appropriate paths where necessary). | |
%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe -STA -Command "&{$Module = [IO.File]::ReadAllText([Environment]::GetFolderPath("""Desktop""")+"""\Minecraft_Launcher.ps1""");Invoke-Expression $Module}" |
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
$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