// +build windows package tools import ( "os" "b612.me/wincmd" "github.com/spf13/cobra" ) var uaccmd = &cobra.Command{ Use: "uac", Short: "Windows 使用uac权限打开文件", Long: "Windows 使用uac权限打开文件", Run: func(this *cobra.Command, args []string) { if len(args) == 0 { return } cmdLine := "" if len(args) > 1 { for _, v := range args[1:] { cmdLine += v + " " } } pwd, _ := os.Getwd() wincmd.StartProcess(args[0], cmdLine, pwd, true, 1) }, } func init() { Maincmd.AddCommand(uaccmd) }