added --silent and register values in windows registry keys
This commit is contained in:
parent
48473f98c5
commit
ca57775f8f
7 changed files with 402 additions and 165 deletions
68
spm/run_win.go
Normal file
68
spm/run_win.go
Normal file
|
@ -0,0 +1,68 @@
|
|||
// run_windows.go
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package spm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Run locates and starts the installed Spitfire browser without waiting for it to exit.
|
||||
func Run() error {
|
||||
installDir, err := GetInstallDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
exePath := filepath.Join(installDir, "browser", "spitfire.exe")
|
||||
if runtime.GOOS != "windows" {
|
||||
exePath = filepath.Join(installDir, "browser", "spitfire")
|
||||
}
|
||||
|
||||
cmd := exec.Command(exePath)
|
||||
cmd.Dir = filepath.Join(installDir, "browser")
|
||||
return cmd.Start()
|
||||
}
|
||||
|
||||
// RunAndWait locates and starts the installed Spitfire browser and waits for it to exit.
|
||||
func RunAndWait() error {
|
||||
installDir, err := GetInstallDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get install directory: %w", err)
|
||||
}
|
||||
|
||||
// Construct the browser executable path
|
||||
exePath := filepath.Join(installDir, "browser", "spitfire.exe")
|
||||
if _, err := os.Stat(exePath); err != nil {
|
||||
return fmt.Errorf("browser executable not found at %s: %w", exePath, err)
|
||||
}
|
||||
|
||||
cmd := exec.Command(exePath)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
|
||||
// Use CREATE_NEW_PROCESS_GROUP flag for Windows
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{
|
||||
CreationFlags: syscall.CREATE_NEW_PROCESS_GROUP,
|
||||
}
|
||||
|
||||
fmt.Printf("Starting browser: %s\n", exePath)
|
||||
if err := cmd.Start(); err != nil {
|
||||
return fmt.Errorf("failed to start browser: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Browser process started with PID %d\n", cmd.Process.Pid)
|
||||
|
||||
if err := cmd.Wait(); err != nil {
|
||||
return fmt.Errorf("browser exited with error: %w", err)
|
||||
}
|
||||
|
||||
fmt.Println("Browser exited successfully.")
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue