5050# #
5151# #################################################################
5252
53+ # Check if running with administrator privileges
54+ if (-NOT ([Security.Principal.WindowsPrincipal ] [Security.Principal.WindowsIdentity ]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole ] " Administrator" )) {
55+ Write-Host " ERROR: This script requires administrator privileges to modify registry keys." - ForegroundColor Red
56+ Write-Host " Please run this script as an administrator:" - ForegroundColor Yellow
57+ Write-Host " 1. Right-click on PowerShell" - ForegroundColor Yellow
58+ Write-Host " 2. Select 'Run as administrator'" - ForegroundColor Yellow
59+ Write-Host " 3. Re-run this script" - ForegroundColor Yellow
60+ Write-Host " "
61+ Write-Host " Press any key to exit..."
62+ $null = $Host.UI.RawUI.ReadKey (" NoEcho,IncludeKeyDown" )
63+ exit 1
64+ }
65+
5366# Setting Values:
5467$MDN = ' 0'
5568$MDWDS = ' 1'
@@ -101,7 +114,7 @@ Clear-Host
101114Write-Host " Setting up your machine to receive Usermode Dumps via WER."
102115Start-Sleep - seconds 3
103116
104-
117+ New-Item - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps " - Force
105118New-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Name " DumpFolder" - Value " %LOCALAPPDATA%\CrashDumps" - PropertyType ExpandString - Force
106119New-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Name " DumpCount" - Value " 10" - PropertyType DWORD - Force
107120
@@ -115,7 +128,7 @@ $NCD = Read-Host "Enter a number option"
115128
116129If ($NCD -eq ' 3' )
117130{
118-
131+ New-Item - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps " - Force
119132 New-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Name " DumpType" - Value " 0" - PropertyType DWORD - Force
120133 Do
121134 {
@@ -239,6 +252,7 @@ If ($NCD -eq '3')
239252 $SumArray = Invoke-Expression $sum
240253 $FinalSum = $0x + $SumArray
241254
255+ New-Item - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Force
242256 New-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Name " CustomDumpFlags" - Value " $FinalSum " - PropertyType DWORD - Force
243257
244258 write-host " "
@@ -263,6 +277,7 @@ ElseIf ($NCD -eq '0')
263277}
264278ElseIf ($NCD -eq ' 1' )
265279{
280+ New-Item - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Force
266281 New-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Name " DumpType" - Value " 2" - PropertyType DWORD - Force
267282 write-host " The computer has been set up to create a Full Sized Dump and will be located in %LOCALAPPDATA%\CrashDumps."
268283 write-host " The computer must also restart for settings to take effect. Would you like to now? (Y/n)"
@@ -277,6 +292,7 @@ ElseIf ($NCD -eq '1')
277292}
278293ElseIf ($NCD -eq ' 2' )
279294{
295+ New-Item - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Force
280296 New-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps" - Name " DumpType" - Value " 1" - PropertyType DWORD - Force
281297 write-host " The computer has been set up to create a Mini Dump and will be located in %LOCALAPPDATA%\CrashDumps."
282298 write-host " The computer must also restart for settings to take effect. Would you like to now? (Y/n)"
0 commit comments