REM Example: elevate myAdminCommand -myArg1 -myArg2 someValue REM Note that any file paths must be fully qualified! REM Executes a command in an elevated PowerShell window and captures/displays output I created two variants, elevatep and elevatex, which respectively pause and keep the PowerShell window open for more work.Īnd in case my link ever dies, here's the code for the original elevate batch file: Off The original elevate command executes its task, captures the output, closes the spawned PowerShell window and then returns, writing out the captured output to the original window. I recommend sticking it in your C:\Windows\System32 folder for ease of use.
Similar to some of the other solutions above, I created an elevate batch file which runs an elevated PowerShell window, bypassing the execution policy to enable running everything from simple commands to batch files to complex PowerShell scripts.