I have the following line that I want to execute from PowerShell:
Start-Process cmd.exe -Credential "doh\account" "`"cd c:\Projects `& dir`""
The problem is that the second command does not execute. I have looked at many articles and have tried multiple combinations of quotes and back ticks without success.
This should do what you want:
Start-Process cmd.exe -credential "doh\account" -ArgumentList "/K cd c:\projects & dir"
I ran "cmd /?" and it has the following argument available: "/K Carries out the command specified by string but remains"
Still not sure why you want to do this though, if you want to elaborate on it we might able help more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With