mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-08-10 00:33:28 +08:00
- 自动迁移引用失效 MSI 缓存图标的旧任务栏固定项并刷新 Shell - 在在线更新前备份桌面快捷方式状态,成功或失败后安全恢复 - 将桌面快捷方式拆分为条件安装组件并补充 Windows 回归测试
55 lines
1.3 KiB
Go
55 lines
1.3 KiB
Go
package app
|
|
|
|
import (
|
|
_ "embed"
|
|
"os/exec"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
//go:embed windows_msi_update.ps1
|
|
var windowsMSIUpdatePowerShellScript string
|
|
|
|
//go:embed windows_shortcut_repair.ps1
|
|
var windowsShortcutRepairPowerShellScript string
|
|
|
|
type windowsMSIUpdateLaunchContext struct {
|
|
SourcePath string
|
|
TargetPath string
|
|
StagedDir string
|
|
LogPath string
|
|
MSILogPath string
|
|
MSIExecPath string
|
|
PID int
|
|
}
|
|
|
|
func buildWindowsMSIUpdatePowerShellScript() string {
|
|
script := windowsShortcutRepairPowerShellScript + "\n\n" + windowsMSIUpdatePowerShellScript
|
|
normalized := strings.ReplaceAll(script, "\r\n", "\n")
|
|
return strings.ReplaceAll(normalized, "\n", "\r\n")
|
|
}
|
|
|
|
func buildWindowsMSILaunchCommand(scriptPath string, context windowsMSIUpdateLaunchContext) *exec.Cmd {
|
|
cmd := exec.Command(
|
|
"powershell.exe",
|
|
"-NoProfile",
|
|
"-NonInteractive",
|
|
"-ExecutionPolicy",
|
|
"Bypass",
|
|
"-File",
|
|
scriptPath,
|
|
)
|
|
cmd.Dir = context.StagedDir
|
|
cmd.Env = append(cmd.Environ(),
|
|
"GONAVI_UPDATE_SOURCE="+context.SourcePath,
|
|
"GONAVI_UPDATE_TARGET="+context.TargetPath,
|
|
"GONAVI_UPDATE_STAGED_DIR="+context.StagedDir,
|
|
"GONAVI_UPDATE_LOG_PATH="+context.LogPath,
|
|
"GONAVI_UPDATE_MSI_LOG_PATH="+context.MSILogPath,
|
|
"GONAVI_UPDATE_MSIEXEC_PATH="+context.MSIExecPath,
|
|
"GONAVI_UPDATE_PID="+strconv.Itoa(context.PID),
|
|
)
|
|
configureWindowsUpdateCommand(cmd)
|
|
return cmd
|
|
}
|