Newer
Older
GoModules / WindowsShortcutFull-Example.go
root on 30 Jan 2022 1 KB Typo
  1. package main
  2.  
  3. import (
  4. "fmt"
  5.  
  6. shortcut "GoModules/Modules/WindowsShortcutFull"
  7. )
  8.  
  9. func main() {
  10.  
  11. /***
  12. * read shortcut data
  13. */
  14. Description, workingDir, targetPath, Arguments, Icon, err := shortcut.Read("C:\\Users\\User\\Desktop\\vlc.lnk")
  15. if err != nil {
  16. print(err)
  17. return false
  18. }
  19. fmt.Printf("[info][Shortcut] C:\\Users\\User\\Desktop\\vlc.lnk\n")
  20. fmt.Printf("[info][Description] %s\n", Description)
  21. fmt.Printf("[info][Working Dir] %s\n", workingDir)
  22. fmt.Printf("[info][Target] %s\n", targetPath)
  23. fmt.Printf("[info][Arguments] %s\n", Arguments)
  24. fmt.Printf("[info][Icon] %s\n", Icon)
  25.  
  26. /***
  27. * create new OR update existing shortcut
  28. */
  29. newTarget := "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"
  30. newArgs := "--fullscreen"
  31. newDescription := "VLC Media Player"
  32. newWorkingDir := "C:\\"
  33. newIcon := "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"
  34.  
  35. err = shortcut.Make("C:\\Users\\User\\Desktop\\vlc.lnk", newDescription, newWorkingDir, newTarget, newArgs, newIcon)
  36. if err != nil {
  37. print(err)
  38. return false
  39. }
  40.  
  41. }
  42.  
Buy Me A Coffee