0

im trying to get a stubborn game to close whenever it freezes. i need an elevated cmd to do so and ive managed to open one using bat;

powershell -Command "Start-Process 'cmd.exe' -Verb runAs"

i then need to run

taskkill /f /pid game.exe

inside of this elevated cmd. any ideas on how to do that?

  • Have you looked at any of the help/usage for the `Start-Process` cmdlet? _`-ArgumentList`_ – Compo Mar 27 '18 at 22:43
  • 1
    Possible duplicate of [Run BAT as admin (w/o shortcut)](https://stackoverflow.com/questions/20117227/run-bat-as-admin-w-o-shortcut) – phuclv Mar 28 '18 at 02:43

1 Answers1

1

If you want to run a command inside the elevated cmd, add -ArgumentList: "/c" tells cmd.exe to run the given command

powershell -Command "Start-Process 'cmd.exe' -ArgumentList @('/c taskkill /f /pid game.exe') -Verb runAs"
Kevin Verstraete
  • 1,363
  • 2
  • 13
  • 13