Skip to content

Commit 24287ac

Browse files
committed
refactor: Remove obsolete analysis file and improve Windows admin privilege check in main.go
- Deleted the outdated analysis file that contained error diagnostics and solutions. - Updated the checkAdminPrivileges function in main.go to use a more reliable method for checking Windows administrator privileges, enhancing security and accuracy. - Fixed a minor display issue in the success message output. - Added "apprun" to the cSpell dictionary in .vscode/settings.json for improved spell checking. These changes streamline the codebase and enhance the functionality of the application.
1 parent 1b69332 commit 24287ac

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"cSpell.words": [
3+
"apprun",
34
"buildmode",
45
"dylib",
56
"endlocal",

analysis

Lines changed: 0 additions & 8 deletions
This file was deleted.

main.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ func showSuccess() {
482482
successColor.Printf("%s\n", text.SuccessMessage)
483483
fmt.Println()
484484
warningColor.Printf("%s\n", text.RestartMessage)
485-
successColor.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━���━━━")
485+
successColor.Println("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")
486486
}
487487

488488
// Add spacing before config location
@@ -527,13 +527,14 @@ func showPrivilegeError() {
527527
func checkAdminPrivileges() (bool, error) {
528528
switch runtime.GOOS {
529529
case "windows":
530-
cmd := exec.Command("whoami", "/groups")
531-
output, err := cmd.Output()
532-
if err != nil {
533-
return false, err
530+
// 使用更可靠的方法检查Windows管理员权限
531+
cmd := exec.Command("net", "session")
532+
err := cmd.Run()
533+
if err == nil {
534+
return true, nil
534535
}
535-
return strings.Contains(string(output), "S-1-16-12288") ||
536-
strings.Contains(string(output), "S-1-5-32-544"), nil
536+
// 如果命令执行失败,说明没有管理员权限
537+
return false, nil
537538

538539
case "darwin", "linux":
539540
currentUser, err := user.Current()
@@ -841,7 +842,7 @@ func main() {
841842
// Progress spinner functions / 进度条函数
842843
func NewProgressSpinner(message string) *ProgressSpinner {
843844
return &ProgressSpinner{
844-
frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "", "⠏"},
845+
frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "��", "⠏"},
845846
message: message,
846847
}
847848
}

0 commit comments

Comments
 (0)