You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
How can I hide the CMD windows that opens when I run a WSL command? I tried the following, but the command object is missing the attribute for hidden window flag. My goal is to run a WSL command without opening a CMD window on Windows 11. Thanks.
// Get the command
cmd := distro.Command(context.Background(), command)
// Ensure to hide the window
cmd.SysProcAttr = &syscall.SysProcAttr{HideWindow: true} // This fails to compile
// Run wsl command and get output
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "Unexpected error: %v\nError message: %s", err, out)
return errors.New("Error: Failed to run command: " + fmt.Sprintf("Unexpected error: %v\nError message: %s", err, out))
} else {
pp.Println("WSL: " + string(out))
return nil
}
The text was updated successfully, but these errors were encountered:
How can I hide the CMD windows that opens when I run a WSL command? I tried the following, but the command object is missing the attribute for hidden window flag. My goal is to run a WSL command without opening a CMD window on Windows 11. Thanks.
The text was updated successfully, but these errors were encountered: