-3

From the regular command prompt (not powershell), I want to run a program that requires admin mode. Since the program is long running, the window must remain open. The program requires command line switches and arguments.

I haven't seen any other post that has all of these requirements.

I stumbled upon a solution but don't understand why the argument passing works. Can someone explain? Is there a more powershell like way of doing the same? A bonus would be to add the ability for making a first-use password prompt and saves the password thereafter.

BSalita
  • 8,420
  • 10
  • 51
  • 68
  • I edited to explain that the command must work within the normal command prompt, not powershell, and be batch file friendly. – BSalita Jun 24 '16 at 12:45
  • Also I don't believe TestComplete's answer will accept switches and arguments. Or at least I don't know how, hence this post. – BSalita Jun 24 '16 at 12:47

1 Answers1

1

The following single line, batch file friendly, command will open an elevated command window, execute the command (with any switches and arguments), and keep the elevated window open.

powershell.exe -Command start-process -verb runas cmd {/K "myprog.py -v all"}
BSalita
  • 8,420
  • 10
  • 51
  • 68