Open notepad -> copy/paste above script -> save it as admin.bat in c:\windowsĪ lot can be added in the above script to make it better but I've tried to keep it simple and also because I'm not an expert in batch scripting. Powershell -Command "Start-Process %1 -Verb RunAs" First one is based on little alteration to Bhaskar's answer and second one is new(that is not mentioned in any answer here).Īpproach 1: Create a admin command for windows(just for the sake of flexibility). PowerShell -Command "& "Ī little late for an answer but answering anyway for latecomers like me. REM If no command is passed, simply open an elevated PowerShell window. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |