diff --git a/script/BootWay.03.ps1 b/script/BootWay.03.ps1 deleted file mode 100644 index d4fb6707..00000000 --- a/script/BootWay.03.ps1 +++ /dev/null @@ -1,45 +0,0 @@ -# Dont Use This Script -# 2024.7.3 -function Get-QQpath { - try { - $key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" - $uninstallString = $key.UninstallString - return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe" - } - catch { - throw "get QQ path error: $_" - } -} -function Select-QQPath { - Add-Type -AssemblyName System.Windows.Forms - [System.Windows.Forms.Application]::EnableVisualStyles() - - $dialogTitle = "Select QQ.exe" - - $filePicker = New-Object System.Windows.Forms.OpenFileDialog - $filePicker.Title = $dialogTitle - $filePicker.Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*" - $filePicker.FilterIndex = 1 - $null = $filePicker.ShowDialog() - if (-not ($filePicker.FileName)) { - throw "User did not select an .exe file." - } - return $filePicker.FileName -} - -$params = $args -join " " -Try { - $QQpath = Get-QQpath -} -Catch { - $QQpath = Select-QQPath -} - -if (!(Test-Path $QQpath)) { - throw "provided QQ path is invalid: $QQpath" -} - -$Bootfile = Join-Path $PSScriptRoot "napcat.mjs" -$env:ELECTRON_RUN_AS_NODE = 1 -$commandInfo = Get-Command $QQpath -ErrorAction Stop -Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{& chcp 65001;& '$($commandInfo.Path)' --enable-logging }" \ No newline at end of file diff --git a/script/BootWay05.bat b/script/BootWay05.bat deleted file mode 100644 index 06d2ee3b..00000000 --- a/script/BootWay05.bat +++ /dev/null @@ -1,90 +0,0 @@ -@echo off -REM 检查当前会话是否具有管理员权限 -openfiles >nul 2>&1 -if %errorlevel% neq 0 ( - REM 如果不是管理员,则重新启动脚本以管理员模式运行 - echo 请求管理员权限... - powershell -Command "Start-Process cmd -ArgumentList '/c %~f0 %*' -Verb RunAs" - exit /b -) - -REM 设置当前工作目录 -cd /d %~dp0 - -REM 获取当前目录路径 -set currentPath=%cd% -set currentPath=%currentPath:\=/% - -REM 生成JavaScript代码 -set "jsCode=(async () =^>await import('file:///%currentPath%/napcat.mjs'))();" - -REM 将JavaScript代码保存到文件中 -echo %jsCode% > loadScript.js -echo JavaScript code has been generated and saved to loadScript.js - -REM 设置NAPCAT_PATH环境变量为 当前目录的loadScript.js地址 -set NAPCAT_PATH=%cd%\loadScript.js - -REM 获取QQ路径 - - -: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 - goto :napcat_boot -) - -:napcat_boot -for %%a in (%RetString%) do ( - set "pathWithoutUninstall=%%~dpa" -) - -SET QQPath=%pathWithoutUninstall%QQ.exe - -REM 拿不到QQ路径则退出 -if not exist "%QQpath%" ( - echo provided QQ path is invalid: %QQpath% - pause - exit /b -) - -REM 收集dbghelp.dll路径和HASH信息 -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 如果文件一致则跳过 -if "%oldDllHash%" neq "%newDllHash%" ( - tasklist /fi "imagename eq QQ.exe" 2>nul | find /i "QQ.exe" >nul - if %errorlevel% equ 0 ( - REM 文件占用则退出 - echo dbghelp.dll is in use, cannot continue. - ) else ( - REM 文件未占用则尝试覆盖 - copy /y "%newDllPath%" "%oldDllPath%" - if %errorlevel% neq 0 ( - echo Failed to copy dbghelp.dll - pause - exit /b - ) else ( - echo dbghelp.dll has been copied to %QQdir% - ) - ) -) - -REM 带参数启动QQ -REM 判断wt是否存在,存在则通过wt启动,不存在则通过cmd启动 -REM %QQPath% --enable-logging %* -where wt >nul 2>nul -if %errorlevel% equ 0 ( - wt "cmd" /c "%QQPath%" --enable-logging %* -) else ( - "%QQPath%" --enable-logging %* -) diff --git a/script/BootWay05.ps1 b/script/BootWay05.ps1 deleted file mode 100644 index 862281ef..00000000 --- a/script/BootWay05.ps1 +++ /dev/null @@ -1,123 +0,0 @@ -# 检查当前会话是否具有管理员权限 -function Test-Administrator { - $user = [Security.Principal.WindowsIdentity]::GetCurrent() - (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) -} - -if (-not (Test-Administrator)) { - # 如果不是管理员,则重新启动脚本以管理员模式运行 - $scriptPath = $myInvocation.MyCommand.Path - if (-not $scriptPath) { - $scriptPath = $PSCommandPath - } - $newProcess = New-Object System.Diagnostics.ProcessStartInfo "powershell"; - $newProcess.Arguments = "-File `"$scriptPath`" $args" - $newProcess.Verb = "runas"; - [System.Diagnostics.Process]::Start($newProcess); - exit -} - -function Get-QQpath { - try { - $key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ" - $uninstallString = $key.UninstallString - return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe" - } - catch { - throw "get QQ path error: $_" - } -} -function Select-QQPath { - Add-Type -AssemblyName System.Windows.Forms - [System.Windows.Forms.Application]::EnableVisualStyles() - - $dialogTitle = "Select QQ.exe" - - $filePicker = New-Object System.Windows.Forms.OpenFileDialog - $filePicker.Title = $dialogTitle - $filePicker.Filter = "Executable Files (*.exe)|*.exe|All Files (*.*)|*.*" - $filePicker.FilterIndex = 1 - $null = $filePicker.ShowDialog() - if (-not ($filePicker.FileName)) { - throw "User did not select an .exe file." - } - return $filePicker.FileName -} - -# 设置当前工作目录 -$scriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent -Set-Location $scriptDirectory - -# 获取当前目录路径 -$currentPath = Get-Location - -# 替换\为/ -$currentPath = $currentPath -replace '\\', '/' - -# 生成JavaScript代码 -$jsCode = @" -(async () => { - await import('file:///$currentPath/napcat.mjs'); -})(); -"@ - -# 将JavaScript代码保存到文件中 -$jsFilePath = Join-Path $currentPath "loadScript.js" -$jsCode | Out-File -FilePath $jsFilePath -Encoding UTF8 - -Write-Output "JavaScript code has been generated and saved to $jsFilePath" -# 设置NAPCAT_PATH环境变量为 当前目录的loadScript.js地址 -$env:NAPCAT_PATH = $jsFilePath - -$params = $args -join " " -Try { - $QQpath = Get-QQpath -} -Catch { - $QQpath = Select-QQPath -} -# 拿不到QQ路径则退出 -if (!(Test-Path $QQpath)) { - Write-Output "provided QQ path is invalid: $QQpath" - Read-Host "Press any key to continue..." - exit -} - -$commandInfo = Get-Command $QQpath -ErrorAction Stop - -# 收集dbghelp.dll路径和HASH信息 -$QQpath = Split-Path $QQpath -$oldDllPath = Join-Path $QQpath "dbghelp.dll" -$oldDllHash = Get-FileHash $oldDllPath -Algorithm MD5 -$newDllPath = Join-Path $currentPath "dbghelp.dll" -$newDllHash = Get-FileHash $newDllPath -Algorithm MD5 -# 如果文件一致则跳过 -if ($oldDllHash.Hash -ne $newDllHash.Hash) { - $processes = Get-Process -Name QQ -ErrorAction SilentlyContinue - if ($processes) { - # 文件占用则退出 - Write-Output "dbghelp.dll is in use by the following processes:" - $processes | ForEach-Object { Write-Output "$($_.Id) $($_.Name) $($_.Path)" } - Write-Output "dbghelp.dll is in use, cannot continue." - Read-Host "Press any key to continue..." - exit - } else { - # 文件未占用则尝试覆盖 - try { - Copy-Item -Path "$newDllPath" -Destination "$oldDllPath" -Force - Write-Output "dbghelp.dll has been copied to $QQpath" - } catch { - Write-Output "Failed to copy dbghelp.dll: $_" - Read-Host "Press any key to continue..." - exit - } - } -} - -# 带参数启动QQ -try { - Start-Process powershell -ArgumentList '-noexit', '-noprofile', "-command &{& chcp 65001;& '$($commandInfo.Path)' --enable-logging $params}" -NoNewWindow -ErrorAction Stop -} catch { - Write-Output "Failed to start process as administrator: $_" - Read-Host "Press any key to continue..." -} \ No newline at end of file diff --git a/script/BootWay05.utf8.bat b/script/BootWay05.utf8.bat deleted file mode 100644 index 2836a38a..00000000 --- a/script/BootWay05.utf8.bat +++ /dev/null @@ -1,93 +0,0 @@ -@echo off -REM 检查当前会话是否具有管理员权限 -openfiles >nul 2>&1 -if %errorlevel% neq 0 ( - REM 如果不是管理员,则重新启动脚本以管理员模式运行 - echo 请求管理员权限... - where wt >nul 2>nul - if %errorlevel% equ 0 ( - powershell -Command "Start-Process cmd -ArgumentList ' /c %~f0 %*' -Verb RunAs" - ) else ( - powershell -Command "Start-Process wt -ArgumentList 'cmd /c %~f0 %*' -Verb RunAs" - ) - - REM wt "cmd" /c "%~f0 %*" - exit /b -) - -REM 设置当前工作目录 -cd /d %~dp0 - -REM 获取当前目录路径 -set currentPath=%cd% -set currentPath=%currentPath:\=/% - -REM 生成JavaScript代码 -set "jsCode=(async () =^>await import('file:///%currentPath%/napcat.mjs'))();" - -REM 将JavaScript代码保存到文件中 -echo %jsCode% > loadScript.js -echo JavaScript code has been generated and saved to loadScript.js - -REM 设置NAPCAT_PATH环境变量为 当前目录的loadScript.js地址 -set NAPCAT_PATH=%cd%\loadScript.js - -REM 获取QQ路径 - - -: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 - goto :napcat_boot -) - -:napcat_boot -for %%a in (%RetString%) do ( - set "pathWithoutUninstall=%%~dpa" -) - -SET QQPath=%pathWithoutUninstall%QQ.exe - -REM 拿不到QQ路径则退出 -if not exist "%QQpath%" ( - echo provided QQ path is invalid: %QQpath% - pause - exit /b -) - -REM 收集dbghelp.dll路径和HASH信息 -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 如果文件一致则跳过 -if "%oldDllHash%" neq "%newDllHash%" ( - tasklist /fi "imagename eq QQ.exe" 2>nul | find /i "QQ.exe" >nul - if %errorlevel% equ 0 ( - REM 文件占用则退出 - echo dbghelp.dll is in use, cannot continue. - ) else ( - REM 文件未占用则尝试覆盖 - copy /y "%newDllPath%" "%oldDllPath%" - if %errorlevel% neq 0 ( - echo Failed to copy dbghelp.dll - pause - exit /b - ) else ( - echo dbghelp.dll has been copied to %QQdir% - ) - ) -) - -REM 带参数启动QQ -REM 判断wt是否存在,存在则通过wt启动,不存在则通过cmd启动 -REM %QQPath% --enable-logging %* -chcp 65001 -"%QQPath%" --enable-logging %* diff --git a/script/BootWay05_init.bat b/script/BootWay05_init.bat deleted file mode 100644 index 654f80fe..00000000 --- a/script/BootWay05_init.bat +++ /dev/null @@ -1,77 +0,0 @@ -@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 - ) - ) -) diff --git a/script/BootWay05_run.bat b/script/BootWay05_run.bat deleted file mode 100644 index db9b2fa7..00000000 --- a/script/BootWay05_run.bat +++ /dev/null @@ -1,10 +0,0 @@ -@echo off -set /p QQPath=