Detect if Powershell or CMD with Rust
I'm writing a CLI app in Rust and need to run commands differently depending on if it is being run in CMD or Powershell. There's this SO question that gives a command "(dir 2>&1 *`|echo CMD);&<# rem #>echo POWERSHELL" to run to output "CMD" or "POWERSHELL", but I can't run that as a Command in Rust. This code returns the following error: Error { kind: NotFound, message: "program not found" } let output = Command::new("(dir 2>&1 *`|echo CMD);&<# rem #>echo POWERSHELL") .output(); The problem is that some CMD/PowerShell commands don't work from Rust's std::process::Command and need to be called
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.