You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
549 B
Go
34 lines
549 B
Go
5 years ago
|
// +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)
|
||
|
}
|