What I want to achieve for my application, is to not need to right click and choose Run as administrator each time I want to run it. I want Windows to prompt me to gain admin permissions as with other windows applications.
consider the following code:
package main
import (
"fmt"
"io/ioutil"
"time"
)
func main() {
err := ioutil.WriteFile("C:/Windows/test.txt", []byte("TESTING!"), 0644)
if err != nil {
fmt.Println(err.Error())
time.Sleep(time.Second * 3)
}
}
If you compile it and double click on it it will print:
open: C:\Windows\test.txt: Access is denied.
But if you right-click and run as administrator, it will create and write the file.
How to make it ask for the admin permission just by double clicking on it?