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.

Revisions

  1. whiskerz007 revised this gist Dec 23, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Minecraft_Launcher.ps1
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ function Start-MCLauncher
    Start-Process ${env:ProgramFiles(x86)}\Minecraft\MinecraftLauncher.exe -Wait True
    }

    Write-Host "`n`nAfter Minecraft Launcher starts and fully authenticates, close the Minecraft Launcher."
    Write-Host "`n`nAfter Minecraft Launcher starts and fully authenticates, close it."
    Write-Host "Starting Minecraft Launcher for initial authentication..."
    Start-MCLauncher

  2. whiskerz007 revised this gist Dec 23, 2016. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Minecraft_Launcher.ps1
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,7 @@ function Start-MCLauncher
    Start-Process ${env:ProgramFiles(x86)}\Minecraft\MinecraftLauncher.exe -Wait True
    }

    Write-Host "`n`nAfter Minecraft Launcher starts and fully authenticates, close the Minecraft Launcher."
    Write-Host "Starting Minecraft Launcher for initial authentication..."
    Start-MCLauncher

    @@ -22,5 +23,5 @@ Out-MCLauncherProfiles $MCNewDisplayName
    Write-Host "Starting Minecraft Launcher with new displayName..."
    Start-MCLauncher

    Write-Host "Restoring original Minecraft displayName to '$MCOriginalDisplayName'..."
    Write-Host "Restoring original Minecraft displayName to '$MCOldDisplayName'..."
    Out-MCLauncherProfiles $MCOldDisplayName
  3. whiskerz007 created this gist Dec 23, 2016.
    26 changes: 26 additions & 0 deletions Minecraft_Launcher.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    $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 "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 '$MCOriginalDisplayName'..."
    Out-MCLauncherProfiles $MCOldDisplayName
    5 changes: 5 additions & 0 deletions link.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    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}"