Skip to content

Commit

Permalink
Remove importing profiles for current user option
Browse files Browse the repository at this point in the history
  • Loading branch information
jtaczanowski committed Jul 19, 2023
1 parent 7a68d50 commit 06c2603
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ func main() {

// This struct represents our main window.
type MyWindow struct {
wnd ui.WindowMain
btnExport ui.Button
btnImportCurrentUser ui.Button
btnImportAllUsers ui.Button
lblInfo ui.Static
importForAllUsers bool
wnd ui.WindowMain
btnExport ui.Button
btnImportAllUsers ui.Button
lblInfo ui.Static
}

func (me *MyWindow) exportProfilesFunction() {
Expand Down Expand Up @@ -85,12 +83,7 @@ func (me *MyWindow) importProfilesFunction() {
stdOutAll := ""
errAll := ""
for _, filePath := range filePaths {
cmd := exec.Command("netsh", "wlan", "add", "profile", fmt.Sprintf("filename=%s", filePath), fmt.Sprintf("user=%s", func() string {
if me.importForAllUsers {
return "all"
}
return "current"
}()))
cmd := exec.Command("netsh", "wlan", "add", "profile", fmt.Sprintf("filename=%s", filePath), "user=all")
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 0x08000000}
stdout, err := cmd.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -126,20 +119,14 @@ func NewMyWindow() *MyWindow {
btnExport: ui.NewButton(wnd,
ui.ButtonOpts().
Text("&Export WiFi profiles").
Position(win.POINT{X: 10, Y: 5}).
Size(win.SIZE{Cx: 200, Cy: 26}),
),
btnImportCurrentUser: ui.NewButton(wnd,
ui.ButtonOpts().
Text("&Import WiFi profiles for current user").
Position(win.POINT{X: 10, Y: 35}).
Size(win.SIZE{Cx: 200, Cy: 26}),
Position(win.POINT{X: 10, Y: 18}).
Size(win.SIZE{Cx: 200, Cy: 39}),
),
btnImportAllUsers: ui.NewButton(wnd,
ui.ButtonOpts().
Text("&Import WiFi profiles for all users").
Position(win.POINT{X: 10, Y: 65}).
Size(win.SIZE{Cx: 200, Cy: 26}),
Text("&Import WiFi profiles").
Position(win.POINT{X: 10, Y: 52}).
Size(win.SIZE{Cx: 200, Cy: 39}),
),
lblInfo: ui.NewStatic(wnd,
ui.StaticOpts().
Expand All @@ -151,13 +138,7 @@ func NewMyWindow() *MyWindow {

me.btnExport.On().BnClicked(me.exportProfilesFunction)

me.btnImportCurrentUser.On().BnClicked(func() {
me.importForAllUsers = false
me.importProfilesFunction()
})

me.btnImportAllUsers.On().BnClicked(func() {
me.importForAllUsers = true
me.importProfilesFunction()
})

Expand Down

0 comments on commit 06c2603

Please sign in to comment.