diff --git a/Makefile b/Makefile index 6de5891..deb15d5 100644 --- a/Makefile +++ b/Makefile @@ -78,7 +78,8 @@ launcher-windows: build-windows if exist "bin\windows\Aminal" rmdir /S /Q "bin\windows\Aminal" mkdir "bin\windows\Aminal\Versions\${VERSION}" go build -o "bin\windows\Aminal\${BINARY}.exe" -ldflags "-H windowsgui" "${GEN_SRC_DIR}\launcher" - copy ${BINARY}-windows-amd64.exe "bin\windows\Aminal\Versions\${VERSION}\${BINARY}.exe" /Y + windres -o aminal.syso aminal.rc + go build -o "bin\windows\Aminal\Versions\${VERSION}\${BINARY}.exe" -ldflags "-H windowsgui" IF "${WINDOWS_CODESIGNING_CERT_PW}"=="" ECHO Environment variable WINDOWS_CODESIGNING_CERT_PW is not defined. & exit 1 signtool sign /f windows\codesigning_certificate.pfx /p "${WINDOWS_CODESIGNING_CERT_PW}" /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp bin\windows\Aminal\${BINARY}.exe signtool sign /f windows\codesigning_certificate.pfx /p "${WINDOWS_CODESIGNING_CERT_PW}" /tr http://sha256timestamp.ws.symantec.com/sha256/timestamp /as /fd sha256 /td sha256 bin\windows\Aminal\${BINARY}.exe diff --git a/windows/launcher/launcher.go b/windows/launcher/launcher.go index cd5cc5f..73098d8 100644 --- a/windows/launcher/launcher.go +++ b/windows/launcher/launcher.go @@ -23,10 +23,12 @@ import ( "io/ioutil" "os" "os/exec" + "os/user" "path/filepath" "sort" "strconv" "strings" + "syscall" ) type Version struct { @@ -42,8 +44,23 @@ func main() { versionsDir := filepath.Join(executableDir, "Versions") latestVersion, err := getLatestVersion(versionsDir) check(err) - target := filepath.Join(versionsDir, latestVersion, executableName) - cmd := exec.Command(target, os.Args[1:]...) + usr, err := user.Current() + check(err) + cmd := exec.Command("C:\\Windows\\System32\\cmd.exe", "/C", "start", "Aminal", "/B", executableName) + cmd.Dir = usr.HomeDir + latestVersionDir := filepath.Join(versionsDir, latestVersion) + path, pathSet := os.LookupEnv("PATH") + if pathSet { + path += ";" + latestVersionDir + } else { + path = latestVersionDir + } + cmd.Env = append(os.Environ(), "PATH="+path) + const CREATE_NO_WINDOW = 0x08000000 + cmd.SysProcAttr = &syscall.SysProcAttr{ + HideWindow: true, + CreationFlags: CREATE_NO_WINDOW, + } check(cmd.Start()) }