refactor: powershell script

This commit is contained in:
手瓜一十雪
2024-05-17 19:22:36 +08:00
parent 093a7be8d1
commit 61112939f0
43 changed files with 95 additions and 55 deletions

View File

@@ -3,19 +3,34 @@ function Get-QQpath {
$key = Get-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\QQ"
$uninstallString = $key.UninstallString
return [System.IO.Path]::GetDirectoryName($uninstallString) + "\QQ.exe"
} catch {
}
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 = Read-Host -Prompt "select QQ path"
if (!$QQpath) {
Write-Host "not select QQ path, exit"
exit
}
}
Catch {
$QQpath = Select-QQPath
}
if (!(Test-Path $QQpath)) {