diff --git a/script/napcat-9912-utf8.bat b/script/napcat-9912-utf8.bat new file mode 100644 index 00000000..2fec84db --- /dev/null +++ b/script/napcat-9912-utf8.bat @@ -0,0 +1,18 @@ +@echo off +setlocal enabledelayedexpansion +chcp 65001 +: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!" +cd /d !QQPath! +echo !QQPath! +QQ.exe --enable-logging %* \ No newline at end of file diff --git a/script/napcat-9912-utf8.ps1 b/script/napcat-9912-utf8.ps1 new file mode 100644 index 00000000..640dabe3 --- /dev/null +++ b/script/napcat-9912-utf8.ps1 @@ -0,0 +1,41 @@ +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) + "\" + } + 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" +} + +Set-Location -Path $QQpath +Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{& chcp 65001;& ./QQ.exe --enable-logging $params}" diff --git a/script/napcat-9912.bat b/script/napcat-9912.bat new file mode 100644 index 00000000..c45e2303 --- /dev/null +++ b/script/napcat-9912.bat @@ -0,0 +1,17 @@ +@echo off +setlocal enabledelayedexpansion +: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! +cd /d !QQPath! +echo !QQPath! +QQ.exe --enable-logging %* \ No newline at end of file diff --git a/script/napcat-9912.ps1 b/script/napcat-9912.ps1 new file mode 100644 index 00000000..b506f512 --- /dev/null +++ b/script/napcat-9912.ps1 @@ -0,0 +1,41 @@ +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) + "\" + } + 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" +} + +Set-Location -Path $QQpath +Start-Process powershell -ArgumentList "-noexit", "-noprofile", "-command &{& ./QQ.exe --enable-logging $params}" \ No newline at end of file diff --git a/vite.config.ts b/vite.config.ts index 8e265596..486f46af 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -28,9 +28,9 @@ if (process.env.NAPCAT_BUILDSYS == 'linux') { } else if (process.env.NAPCAT_BUILDSYS == 'win32') { if (process.env.NAPCAT_BUILDARCH == 'x64') { } - startScripts = ['./script/napcat.ps1', './script/napcat.bat', './script/napcat-utf8.bat', './script/napcat-utf8.ps1', './script/napcat-log.ps1','./script/NapCat.164.bat']; + startScripts = ['./script/napcat.ps1', './script/napcat.bat', './script/napcat-utf8.bat', './script/napcat-utf8.ps1', './script/napcat-log.ps1','./script/NapCat.164.bat','./script/napcat-9912.ps1','./script/napcat-9912-utf8.ps1','./script/napcat-9912.bat','./script/napcat-9912-utf8.bat']; } else { - startScripts = ['./script/napcat.sh', './script/napcat.ps1', './script/napcat.bat', './script/napcat-utf8.bat', './script/napcat-utf8.ps1', './script/napcat-log.ps1']; + startScripts = ['./script/napcat.sh', './script/napcat.ps1', './script/napcat.bat', './script/napcat-utf8.bat', './script/napcat-utf8.ps1', './script/napcat-log.ps1','./script/napcat-9912.ps1','./script/napcat-9912-utf8.ps1','./script/napcat-9912.bat','./script/napcat-9912-utf8.bat']; } const baseConfigPlugin: PluginOption[] = [