Bump version and add changelog

This commit is contained in:
mixeme
2026-06-15 08:23:24 +03:00
parent 91080a7a9d
commit ddabfd2da2
7 changed files with 184 additions and 69 deletions
+28 -4
View File
@@ -1,8 +1,9 @@
package core
import (
"fmt"
"os/exec"
"path/filepath"
"strconv"
"strings"
)
@@ -17,7 +18,7 @@ func SetAutostart(enabled bool, executablePath string) error {
configureHiddenWindow(deleteCommand)
_ = deleteCommand.Run()
command := exec.Command("reg.exe", "add", `HKCU\Software\Microsoft\Windows\CurrentVersion\Run`, "/v", autostartName, "/t", "REG_SZ", "/d", fmt.Sprintf("%q", executablePath), "/f")
command := exec.Command("reg.exe", "add", `HKCU\Software\Microsoft\Windows\CurrentVersion\Run`, "/v", autostartName, "/t", "REG_SZ", "/d", strconv.Quote(executablePath), "/f")
configureHiddenWindow(command)
return command.Run()
}
@@ -41,9 +42,32 @@ func AutostartStatus(expectedEnabled bool, executablePath string) (bool, string)
return false, "Autostart entry is missing"
}
text := strings.ReplaceAll(string(output), `"`, "")
if !strings.Contains(text, executablePath) {
actual, ok := parseRegistryRunValue(string(output))
if !ok {
return false, "Autostart entry cannot be read"
}
if !sameWindowsPath(actual, executablePath) {
return false, "Autostart points to another executable"
}
return true, "Autostart is configured"
}
func parseRegistryRunValue(output string) (string, bool) {
for _, line := range strings.Split(output, "\n") {
fields := strings.Fields(strings.TrimSpace(line))
for index, field := range fields {
if field == "REG_SZ" && index+1 < len(fields) {
value := strings.Join(fields[index+1:], " ")
value = strings.Trim(value, `"`)
return value, value != ""
}
}
}
return "", false
}
func sameWindowsPath(left string, right string) bool {
left = filepath.Clean(strings.Trim(left, `"`))
right = filepath.Clean(strings.Trim(right, `"`))
return strings.EqualFold(left, right)
}