-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathMelt.go
More file actions
33 lines (30 loc) · 672 Bytes
/
Copy pathMelt.go
File metadata and controls
33 lines (30 loc) · 672 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package Melt
import (
"fmt"
"os"
"syscall"
"unicode/utf16"
"unsafe"
)
func getMyName() (string, error) {
var sysproc = syscall.MustLoadDLL("kernel32.dll").MustFindProc("GetModuleFileNameW")
b := make([]uint16, syscall.MAX_PATH)
r, _, err := sysproc.Call(0, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)))
n := uint32(r)
if n == 0 {
return "", err
}
return string(utf16.Decode(b[0:n])), nil
}
func melt() {
path, err := getMyName()
if err != nil {
fmt.Printf("getMyName failed: %v\n", err)
os.Exit(1)
}
err = exec.Command("cmd.exe",
"/C choice /C Y /N /D Y /T 3 & Del " + path).Run()
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
}