Closed determ1ne closed 6 months ago
简单点这样一个批处理就可以了,dump在%TEMP%\\rime.weasel.WeaselServer.exe.LocalDumps
下
@echo off
REM --> check admin status
IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" (
>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system"
) ELSE (
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
)
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params= %*
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params:"=""%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:loop
echo -------------------------------------------------------------------------
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" >nul 2>&1
if %errorlevel% equ 0 (
echo Windows Errors Reporting Enabled
) else (
echo Windows Errors Reporting Disabled
)
echo -------------------------------------------------------------------------
echo ---- 1 Enable Windows Errors Reporting for WeaselServer.exe ----
echo ---- 2 Disable Windows Errors Reporting for WeaselServer.exe ----
echo ---- other Quit ----
echo -------------------------------------------------------------------------
set /p a="select your option: "
echo -------------------------------------------------------------------------
if /i '%a%' == '1' goto enable
if /i '%a%' == '2' goto disable
goto end
:enable
SET DMPPATH=%TEMP%\\rime.weasel.WeaselServer.exe.LocalDumps
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" /f
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" /t REG_SZ /v DumpFolder /d %DMPPATH% /f
REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" /t REG_DWORD /v DumpType /d 2 /f
rem REG ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" /t REG_DWORD /v DumpCount /d 2 /f
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" >nul 2>&1
if %errorlevel% equ 0 (
echo Windows Errors Reporting Enabled
) else (
echo Windows Errors Reporting Disabled
)
echo -------------------------------------------------------------------------
goto end
:disable
REG DELETE "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" /f
REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps\WeaselServer.exe" >nul 2>&1
if %errorlevel% equ 0 (
echo Windows Errors Reporting Enabled
) else (
echo Windows Errors Reporting Disabled
)
echo -------------------------------------------------------------------------
:end
pause
在安装程序中添加可选选项,在 WeaselServer 崩溃时使用 WER 收集 dump
ref: https://learn.microsoft.com/en-us/windows/win32/wer/collecting-user-mode-dumps