Skip to content

Instantly share code, notes, and snippets.

@robot56
Last active August 29, 2015 14:27
Show Gist options
  • Save robot56/bc6e16499549d74e8ea2 to your computer and use it in GitHub Desktop.
Save robot56/bc6e16499549d74e8ea2 to your computer and use it in GitHub Desktop.
@echo off
Setlocal EnableDelayedExpansion
title Minecraft Windows 10 Edition Launch debugger
echo Minecraft Windows 10 Edition Launch debugger
echo.
echo.
echo Contact Extreme_Heat on http://minecraftforum.net/ or Extreme on irc.esper.net for help with this file
echo.
echo -----------------------
echo Writing files...
:: CONFIG
set FLAGS=""
set OUTFILE="MCW10Edition-ExitCodeCheck.ps1"
echo # Minecraft Windows 10 Edition - Launch debugger > %OUTFILE%
echo # >> %OUTFILE%
echo Add-Type -AssemblyName System.Windows.Forms; >> %OUTFILE%
echo $MessageBox = [System.Windows.Forms.MessageBox]; >> %OUTFILE%
echo # >> %OUTFILE%
echo function exportEventLog($logName, $exportLocation) { >> %OUTFILE%
echo # The following function exports events from the event log >> %OUTFILE%
echo # Based on (c) 2011 Thomas Maurer -- http://www.thomasmaurer.ch/2011/05/powershell-how-to-export-windows-eventlogs-with-powershell/ >> %OUTFILE%
echo $exportFileName = $LogName + "-" + (get-date -f yyyyMMdd) + ".evt"; >> %OUTFILE%
echo $logFile = Get-WmiObject Win32_NTEventlogFile ^| Where-Object {$_.logfilename -eq $logName}; >> %OUTFILE%
echo Write-Output $logFile; >> %OUTFILE%
echo Write-Output ($exportLocation + $exportFileName); >> %OUTFILE%
echo $logFile.backupeventlog($exportLocation + $exportFileName); >> %OUTFILE%
echo } >> %OUTFILE%
echo # >> %OUTFILE%
echo function clearEventLog($logName) { >> %OUTFILE%
echo Clear-Eventlog -LogName $logName; >> %OUTFILE%
echo } >> %OUTFILE%
echo # >> %OUTFILE%
echo function clearAndExportLog($logNames, $exportLocation) { >> %OUTFILE%
echo $doClear = $MessageBox^:^:Show("It is recommended that the Event logs are cleared prior to the running of this script. This helps to ensure that unrelated events do not fill up the script output.`n`nSelect `"OK`" to automatically backup and clear the Event log (select `"Yes`" on the upcoming prompt), or press `"Cancel`" to skip this process.", "Request for elevation", 1, "Question"); >> %OUTFILE%
echo if ($doClear -eq "Cancel") { >> %OUTFILE%
echo Write-Output "User requested no event clearing."; >> %OUTFILE%
echo return; >> %OUTFILE%
echo } >> %OUTFILE%
echo $command = ""; >> %OUTFILE%
echo foreach ($logName in $logNames) { >> %OUTFILE%
echo $exportFileName = $logName.replace("/","#") + "-" + (get-date -f yyyyMMdds) + ".evt"; >> %OUTFILE%
echo $exportFileLocation = $exportLocation + $exportFileName; >> %OUTFILE%
echo $command = $command + "wevtutil clear-log " + $logName + " /backup:" + $exportFileLocation + " `&`& "; >> %OUTFILE%
echo } >> %OUTFILE%
echo $command = $command + "exit"; >> %OUTFILE%
echo Write-Output $command; >> %OUTFILE%
echo Start-Process cmd -ArgumentList ('/c ' + $command) -Verb runAs; >> %OUTFILE%
echo #wevtutil clear-log $logName /backup:$exportFileLocation; >> %OUTFILE%
echo } >> %OUTFILE%
echo # >> %OUTFILE%
echo # begin patch 2015-08-19 >> %OUTFILE%
echo function toBase64($data) { >> %OUTFILE%
echo [System.Convert]^:^:ToBase64String([System.Text.Encoding]^:^:UTF8.GetBytes($data)); >> %OUTFILE%
echo } >> %OUTFILE%
echo # >> %OUTFILE%
echo Write-Output "Checking the UserProfile data."; >> %OUTFILE%
echo # >> %OUTFILE%
echo $LocalDataPath = $env:LOCALAPPDATA + "\Packages\" + (Get-AppxPackage -Name Microsoft.MinecraftUWP).PackageFamilyName; >> %OUTFILE%
echo # >> %OUTFILE%
echo $Base64Path = toBase64 $LocalDataPath; >> %OUTFILE%
echo # >> %OUTFILE%
echo Write-Output "Data should be path should be the following:"; >> %OUTFILE%
echo Write-Output $Base64Path; >> %OUTFILE%
echo # end patch 2015-08-19 >> %OUTFILE%
echo $logs = @( >> %OUTFILE%
echo "Application", # Application event viewer log >> %OUTFILE%
echo "System", # System event viewer log >> %OUTFILE%
echo "Microsoft-Windows-TWinUI/Operational" # Windows Store app container log (Applications and Services Logs -> "Microsoft" -> "Windows" -> "Apps" -> "Microsoft-Windows-TWinUI/Operational" >> %OUTFILE%
echo ); >> %OUTFILE%
echo # >> %OUTFILE%
echo # >> %OUTFILE%
echo $logDirectory = $env:ProgramData + "\Microsoft\Windows\WER\Temp\"; >> %OUTFILE%
echo Write-Output ("Saving and clearing the following Event Viewer logs to " + $logDirectory); >> %OUTFILE%
echo Write-Output $logs; >> %OUTFILE%
echo clearAndExportLog $logs $logDirectory; >> %OUTFILE%
echo # >> %OUTFILE%
echo Write-Output "Starting Minecraft..."; >> %OUTFILE%
echo # >> %OUTFILE%
echo explorer shell:AppsFolder\Microsoft.MinecraftUWP_8wekyb3d8bbwe^^!App; >> %OUTFILE%
echo # >> %OUTFILE%
echo Start-Sleep -s 15 >> %OUTFILE%
echo $isProcessActive = Get-Process Minecraft.Win10.DX11 -ErrorAction SilentlyContinue; >> %OUTFILE%
echo if ($isProcessActive) { >> %OUTFILE%
echo Start-Sleep 5; >> %OUTFILE%
echo if (Get-Process Minecraft.Win10.DX11 -ErrorAction SilentlyContinue) { >> %OUTFILE%
echo Stop-Process -Name "Minecraft.Win10.DX11"; >> %OUTFILE%
echo Write-Output "Minecraft successfully ran, no crashes detected."; >> %OUTFILE%
echo $doContinue = $MessageBox^:^:Show("'Minecraft: Windows 10 Edition' was successfully started, no launch issues were detected.`n`nIf errors continue to persist, please contact whoever is helping you or see http://minecraftforum.net/forums/support/.`n`nIf you still wish to collect event logs, press `"OK`".", "Minecraft: Windows 10 Edition", 1, "Warning"); >> %OUTFILE%
echo if ($doContinue -eq "Cancel") { >> %OUTFILE%
echo Write-Output "User requested exit."; >> %OUTFILE%
echo exit; >> %OUTFILE%
echo } >> %OUTFILE%
echo } >> %OUTFILE%
echo } else { >> %OUTFILE%
echo write-output "Minecraft was unexpectedly closed, gathering Event log data..."; >> %OUTFILE%
echo } >> %OUTFILE%
echo # >> %OUTFILE%
echo foreach ($log in $logs) { >> %OUTFILE%
echo Write-Output ("Reading Event Viewer log " + $log + " to " + $logDirectory); >> %OUTFILE%
echo # http://blogs.technet.com/b/ashleymcglone/archive/2013/08/28/powershell-get-winevent-xml-madness-getting-details-from-event-logs.aspx >> %OUTFILE%
echo $events = Get-WinEvent -FilterHashtable @{Logname=$log} -EA SilentlyContinue; >> %OUTFILE%
echo foreach ($event in $events) { >> %OUTFILE%
echo Write-Output "XML:"; >> %OUTFILE%
echo Write-Output $event.ToXml(); >> %OUTFILE%
echo } >> %OUTFILE%
echo Write-Output ("Done."); >> %OUTFILE%
echo } >> %OUTFILE%
echo # >> %OUTFILE%
echo $MessageBox^:^:Show("The script ran successfully.", "Minecraft: Windows 10 Edition", 0, "Asterisk"); >> %OUTFILE%
echo Successfully wrote PowerShell file, running it...
PowerShell -ExecutionPolicy Bypass -File %OUTFILE% %FLAGS% > %UserProfile%\Desktop\MCW10.txt
echo Opening notepad window. Once it opens, copy everything inside it and submit it to https://gist.github.com/ and share the link to whom is assisting you.
notepad %UserProfile%\Desktop\MCW10.txt
del %OUTFILE%
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment