-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: no longer require admin when running after initialization
- Loading branch information
1 parent
147bdfa
commit 560e18a
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@echo off | ||
REM Check if the script is running as administrator | ||
openfiles >nul 2>&1 | ||
if %errorlevel% neq 0 ( | ||
REM If not, restart the script in administrator mode | ||
echo Requesting administrator privileges... | ||
powershell -Command "Start-Process cmd -ArgumentList '/c %~f0 %*' -Verb RunAs" | ||
exit /b | ||
) | ||
|
||
cd /d %~dp0 | ||
|
||
set currentPath=%cd% | ||
set currentPath=%currentPath:\=/% | ||
|
||
REM Generate JavaScript code | ||
set "jsCode=(async () =^>await import('file:///%currentPath%/napcat.mjs'))();" | ||
|
||
REM Save JavaScript code to a file | ||
echo %jsCode% > loadScript.js | ||
echo JavaScript code has been generated and saved to loadScript.js | ||
|
||
REM Set NAPCAT_PATH environment variable to the address of loadScript.js in the current directory | ||
set NAPCAT_PATH=%cd%\loadScript.js | ||
|
||
REM Get QQ path and cache it | ||
:loop_read | ||
for /f "tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" /v "UninstallString"') do ( | ||
set "RetString=%%b" | ||
) | ||
|
||
set "pathWithoutUninstall=%RetString:Uninstall.exe=%" | ||
|
||
SET QQPath=%pathWithoutUninstall%QQ.exe | ||
echo %QQPath%>qq_path_cache.txt | ||
echo QQ path %QQPath% has been cached to qq_path_cache.txt | ||
|
||
REM Exit if QQ path is invalid | ||
if not exist "%QQpath%" ( | ||
echo provided QQ path is invalid: %QQpath% | ||
pause | ||
exit /b | ||
) | ||
|
||
REM Collect dbghelp.dll path and HASH information | ||
set QQdir=%~dp0 | ||
set oldDllPath=%QQdir%dbghelp.dll | ||
set newDllPath=%currentPath%\dbghelp.dll | ||
|
||
for /f "tokens=*" %%A in ('certutil -hashfile "%oldDllPath%" MD5') do ( | ||
if not defined oldDllHash set oldDllHash=%%A | ||
) | ||
for /f "tokens=*" %%A in ('certutil -hashfile "%newDllPath%" MD5') do ( | ||
if not defined newDllHash set newDllHash=%%A | ||
) | ||
|
||
REM Compare the HASH of the old and new dbghelp.dll, and replace the old one if they are different | ||
if "%oldDllHash%" neq "%newDllHash%" ( | ||
tasklist /fi "imagename eq QQ.exe" 2>nul | find /i "QQ.exe" >nul | ||
if %errorlevel% equ 0 ( | ||
REM If the file is in use, prompt the user to close QQ | ||
echo dbghelp.dll is in use, please close QQ first. | ||
) else ( | ||
copy /y "%newDllPath%" "%oldDllPath%" | ||
if %errorlevel% neq 0 ( | ||
echo Copy dbghelp.dll failed, please check and try again. | ||
pause | ||
exit /b | ||
) else ( | ||
echo dbghelp.dll has been updated. | ||
echo Please run BootWay05_run.bat to start QQ. | ||
echo If you update QQ in the future, please run BootWay05_init.bat again. | ||
pause | ||
exit /b | ||
) | ||
) | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@echo off | ||
set /p QQPath=<qq_path_cache.txt | ||
echo QQ path %QQPath% has been read from qq_path_cache.txt | ||
echo If failed to start QQ, please try running this script in administrator mode. | ||
|
||
set NAPCAT_PATH=%cd%\loadScript.js | ||
|
||
REM Launch QQ.exe with params provided | ||
|
||
"%QQPath%" --enable-logging %* |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
@echo off | ||
|
||
chcp 65001 | ||
|
||
set /p QQPath=<qq_path_cache.txt | ||
echo QQ path %QQPath% has been read from qq_path_cache.txt | ||
echo If failed to start QQ, please try running this script in administrator mode. | ||
|
||
set NAPCAT_PATH=%cd%\loadScript.js | ||
|
||
REM Launch QQ.exe with params provided | ||
|
||
"%QQPath%" --enable-logging %* |