title: Launch Elevated CMD.exe from Powershell
body: <p>I am trying to launch an elevated CMD window from PowerShell but I am running into some issues. Below is the Code I have now.  There is an admin account on the machine that has the username of "test" and a Password of "test" </p>
  
  <pre><code>$username = "test"
  $password = ConvertTo-SecureString "test" -AsPlainText -Force
  $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
  Start-Process "cmd.exe" -Credential $cred
  </code></pre>
  
  <p>This is all working fine for running an application from the user profile with no administrator rights that this script sits in, but when calling the cmd.exe it launches as expected with elevated rights but then immediately closes.</p>
  
  <p>I have also tried calling it with the following:</p>
  
  <pre><code>Start-Process "cmd.exe" -Credential $cred -ArgumentList '/k'
  </code></pre>
  
  <p>This also is not working.<br>
  I tested the elevated permissions by passing in an argument as follows and this works fine.</p>
  
  <pre><code>Start-Process "cmd.exe" -Credential $cred -ArgumentList 'dir &gt; dir.txt'
  </code></pre>
  
  <p>This will write out a dir.txt file to the C:\Windows\System32\WindowsPowerShell\v1.0 directory which is blocked on the user account but not for the administrator account test.</p>
  
  <p>Any help on getting a persistent cmd window to show would be greatly appreciated.</p>
  
  <p>Thanks</p>