Skip to content

Commit

Permalink
Fix encoding issue with notification scripts
Browse files Browse the repository at this point in the history
Go uses UTF8 for everything, Windows does not!
Fixes #1191
  • Loading branch information
andydotxyz committed Jul 20, 2020
1 parent 172bae0 commit f9eab2b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/app_windows.go
Expand Up @@ -7,7 +7,6 @@ package app
import (
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
"os/exec"
Expand Down Expand Up @@ -69,18 +68,17 @@ func runScript(name, script string) {
scriptNum++
appID := fyne.CurrentApp().UniqueID()
fileName := fmt.Sprintf("fyne-%s-%s-%d.ps1", appID, name, scriptNum)
log.Println(fileName)

tmpFilePath := filepath.Join(os.TempDir(), fileName)
err := ioutil.WriteFile(tmpFilePath, []byte(script), 0600)
if err != nil {
fyne.LogError("Could not write script to show notification", err)
return
}
log.Println("PATH", tmpFilePath)
defer os.Remove(tmpFilePath)

cmd := exec.Command("PowerShell", "-ExecutionPolicy", "Bypass", "-File", tmpFilePath)
launch := "(Get-Content -Encoding UTF8 -Path " + tmpFilePath + " -Raw) | Invoke-Expression"
cmd := exec.Command("PowerShell", "-ExecutionPolicy", "Bypass", launch)
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true}
err = cmd.Run()
if err != nil {
Expand Down

0 comments on commit f9eab2b

Please sign in to comment.