Skip to content

Commit

Permalink
Merge pull request #26 from lchudinov/bugfix/fix-start-menu-folder-lo…
Browse files Browse the repository at this point in the history
…cation

Fix Start Menu folder location
  • Loading branch information
lchudinov authored Jun 10, 2020
2 parents b870a50 + 90198cf commit 87f47c4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions utils/utils_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ func CreateStartMenuShortcut(src, folder, title, description, iconSrc string, ar
err = errors.Wrapf(err, "unable to create a Start Menu shortcut for %v with title %s", arguments, title)
}
}()
homeDir := os.Getenv("USERPROFILE")
programsDir := filepath.Join(homeDir, "Start Menu", "Programs")
programsDir := getProgramsStartMenuDir()
dir := filepath.Join(programsDir, folder)
if _, err = os.Stat(dir); os.IsNotExist(err) {
err = os.MkdirAll(dir, 0755)
Expand Down Expand Up @@ -303,15 +302,19 @@ func RemoveStartMenuFolder(folder string) error {
err = errors.Wrapf(err, "unable to remove Start Menu folder %s", folder)
}
}()
homeDir := os.Getenv("USERPROFILE")
programsDir := filepath.Join(homeDir, "Start Menu", "Programs")
programsDir := getProgramsStartMenuDir()
dir := filepath.Join(programsDir, folder)
if _, err = os.Stat(dir); os.IsNotExist(err) {
return nil
}
return os.RemoveAll(dir)
}

func getProgramsStartMenuDir() string {
appDataDir := os.Getenv("APPDATA")
return filepath.Join(appDataDir, "Microsoft", "Windows", "Start Menu", "Programs")
}

var (
pMessageBoxW = user32.NewProc("MessageBoxW")
)
Expand Down

0 comments on commit 87f47c4

Please sign in to comment.