Newer
Older
GoModules / WindowsShortcutFull-Example.go
root on 30 Jan 2022 1 KB Typo
package main

import (
	"fmt"

	shortcut "GoModules/Modules/WindowsShortcutFull"
)

func main() {

	/***
	 * read shortcut data
	 */
	Description, workingDir, targetPath, Arguments, Icon, err := shortcut.Read("C:\\Users\\User\\Desktop\\vlc.lnk")
	if err != nil {
		print(err)
		return false
	}
	fmt.Printf("[info][Shortcut] C:\\Users\\User\\Desktop\\vlc.lnk\n")
	fmt.Printf("[info][Description] %s\n", Description)
	fmt.Printf("[info][Working Dir] %s\n", workingDir)
	fmt.Printf("[info][Target] %s\n", targetPath)
	fmt.Printf("[info][Arguments] %s\n", Arguments)
	fmt.Printf("[info][Icon] %s\n", Icon)

	/***
	 * create new OR update existing shortcut
	 */
	newTarget := "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"
	newArgs := "--fullscreen"
	newDescription := "VLC Media Player"
	newWorkingDir := "C:\\"
	newIcon := "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe"

	err = shortcut.Make("C:\\Users\\User\\Desktop\\vlc.lnk", newDescription, newWorkingDir, newTarget, newArgs, newIcon)
	if err != nil {
		print(err)
		return false
	}

}