When I execute the following code:

$creds = Get-Credential -UserName other -Message none
# answering the creds dialogue with correct password here
Start-Process C:\Windows\system32\cmd.exe -Credential $creds

a cmd windows opens (looks completely normal and I can change settings...) but I cannot type anything into the window. Independent of whether it is a normal user or an admin account and the powershell itself is run as normal user or as admin. Except when the Powershell is run as System (via Sysinternal's psexec): then I get the following error:

Start-Process : This command cannot be run due to the error: Access denied
At line:1 char:1
+ Start-Process C:\Windows\system32\cmd.exe -Credential $creds
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Start-Process], InvalidOperationException
    + FullyQualifiedErrorId : InvalidOperationException,Microsoft.PowerShell.Commands.StartProcessCommand

I combined this with cmd.exe and powershell instead of the whole cmd-path and added the -NoNewWindow parameter but nothing of that makes a difference (opens a new window despite the -NoNewWindow). When runnnig "normal" programs like notepad everything works as expected - also when I run e.g. runas /user:other cmd. I currently only have Windows [Version 10.0.17134.165] to test and I am not sure if this is the same on other versions but I think it is Windows 10 specific (?).

Another killjoy flaw in Powershell or am I missing something?


There is definitely something strange going on here: both the starting PowerShell window and the new command prompt seem to stop accepting input after the new process is started. After switching between the two windows a bit, the command prompt temporarily starts accepting keyboard input, but then gets stuck again after executing a command.

You can work around this issue by using the .NET Framework's Process.Start method directly:

$creds = Get-Credential -UserName 'theUser' -Message ' '
[System.Diagnostics.Process]::Start('cmd', $creds.UserName, $creds.Password, '')

The resulting command prompt acts normally, as does the existing PowerShell window. If you don't want PowerShell to output some info about the new process, tack | Out-Null onto the end of the second line.

  • Nevermind, I ran from ISE and VSCode, not the console host where this is an issue. – postanote Jul 26 '18 at 0:57
  • Yeppers, I meant this for the OP. Yet, as I noted in my quick tests, this only happens when doing this from the console host. Which is kind of odd. – postanote Jul 26 '18 at 1:00
  • It's not letting me edit my comment for some reason … Any way.. Yet, I don't get errors either way. The cmd prompt just does not allow interaction. Yet, if we thing about this parent child call, the consolehost has focus when calling cmd.exe. If you use the post, type anything in the non responding cmd, the click the console host, what you typed will appear. So, it's a switch focus thing from my test thus far. – postanote Jul 26 '18 at 1:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.