- When using Powershell, you may need to run Powershell as an administrator to perform a specific task. The reason for this is the User Account Control (UAC). Introduced with Windows Vista User Account Control (UAC) keeps the user in a non-elevated state if not explicitly told to be elevated as an administrator.
- Hi, I was wondering if it is possible to create a powershell script that uses the start-process command allowing me to open up a program (lets say cmd) as the administrator? The reason is I want the ‘do you want to make changes to your pc.’ sign to come up, in order for me to try use send keys to type in the password.
- Powershell Run Bat File As Administrator Manager
- Powershell Run Bat File As Administrator Default
- Powershell Run Batch As Administrator
- Run Powershell Script From Batch File As Administrator
Why call my PowerShell script from a batch file. You can’t double-click to run.PS1 files, but you can execute a.BAT file that way. So, we’ll write a batch file to call the PowerShell script from the command line. There are several good reasons for doing this: Non-technical Users are often tackled with PowerShell. If I finally cave in and choose to launch the shortcut with 'Run as Administrator', the script executes OK - but that merely triggers the very UAC prompt I'm trying to avoid. The account I'm using is an administrator. My script, amongst other things, executes runas.exe to launch a.EXE file under a second admin account. Any bright ideas?
In the Windows operating system, a user account that is a member of the administrators group will not automatically have unrestricted full access to the operating system, thanks to the User Account Control system that has been implemented since Windows Vista. The purpose of the UAC restriction is to prevent malicious software from instantly making changes to any parts of the Windows operating system when it is launched. The User Account Control warning window will help to create an awareness to the user that a program from an unknown publisher wants to make changes to your computer.
As an example, the HOSTS file in Windows is used to map a hostname to an IP address and can be opened and viewed using a text editor such as Notepad. However, in order to save the changes made on the HOSTS file, Notepad must run as administrator or else you’ll get the error window saying “Access is denied.”
An older program that was compiled during the Windows XP era will also face problems if it requires changes in restricted areas because it doesn’t create a UAC prompt to elevate privileges when run. To solve this problem, you can manually run the program as administrator and here we have 10 different ways to do it.
1. Right Click on Program or ShortcutOne of the most common way to run a program with a UAC prompt to elevate privileges is by using your mouse to right click on the program file or shortcut and select “Run as administrator“.
2. Ctrl+Shift+Enter
For the more advanced user who uses the keyboard more than the mouse, a handy method to quickly run a program as administrator is by simultaneously pressing the Ctrl + Shift + Enter key when the program is selected at the Start menu. In fact, Ctrl + Shift + left click will also work.
Do take note that this method strictly works from the Start menu only but not on other areas such as the Desktop or Explorer.
3. Explorer Ribbon Menu
If you love to use the ribbon toolbar menu which was introduced in Microsoft Office 2007, you will find that there is a “Run as administrator” option from the Manage tab in Windows Explorer. Do note that this option is only available on executable files but not on program shortcuts.
You won’t find this in Windows 7 because the ribbon based Explorer has only been implemented since Windows 8.
4. Permanently running program as administrator
It would be quite annoying if you constantly need to manually run the program as administrator because there are times when you’ll forget to do that. Fortunately Microsoft provides a built-in method to permanently configure the program to run as administrator each time you run the program. You can either right click on the program exe file itself or the shortcut, select Properties, go to Compatibility tab, and tick the “Run this program as an administrator” checkbox. Finally click the OK button to apply the changes.
5. From Task Manager
The Task Manager tool in Windows is a useful utility that is commonly used to forcefully terminate a program and to see what process is running. Another very useful feature found in Task Manager that most users don’t know exists is the ability to run a program with administrative privileges without even getting the UAC prompt.
You can quickly launch Task Manager by simultaneously pressing Ctrl+Shift+Esc key, click on File menu, select New Task (Run…) and browse for the program. For Windows 8 and above, you’ll need to click on the More details button located at the bottom left, then only click on File menu bar, select “Run new task”, browse the program and make sure that the “Create this task with administrative privileges” checkbox is ticked.
6. RunAs
RunAs is a command line tool to execute program under a different user account that is available in Windows operating systems since XP. Surprisingly you can use RunAs to launch a program under the same user account and it will have elevated privileges without the UAC prompt. You will however need to enter the user account password and it cannot accept a blank password. The command is as follow:
runas /user:computernameusername 'C:pathtoprogram.exe'
7. PowerShell
PowerShell is a powerful automation tool that comes built in to the Windows operating system. It looks similar to command prompt except it can do so much more, thanks to the scripting language for complex operations. With a single command line below that can be used in batch files or in the Run window, you can launch a program as administrator with a UAC prompt using PowerShell.
powershell.exe -Command 'Start-Process 'C:pathtoprogram.exe' -Verb runAs'
Powershell Run Bat File As Administrator Manager
If you’re running from PowerShell, then you’ll have to omit the command before the Start-Process. For example:
8. Task Scheduler trick
The Task Scheduler trick is a well known workaround method to permanently disable UAC for a specific program without disabling the whole User Account Control feature. It involves quite a few steps to get it to work which may be a bit challenging for beginners to accomplish. Fortunately there are a few third party programs that does the exact same thing but only involves a few clicks of a mouse button.
We’ve tested one of the program called ElevatedShortcut and it works in Windows 10 x64 without problems using the version that was built for Windows 8.
9. Elevate
The third party Elevate command line tool allows you to trigger a UAC elevation prompt for any programs that you specify which is very useful when working with batch files.
As you can see from the screenshot above, it triggers a UAC privilege elevation on Notepad and the user will still need to click on the Yes button to allow the program to run.
10. Vista UAC Maker
When you have a program that can work with or without admin access and you explicitly want to run it with elevated privileges every time, an official solution is to embed a manifest file into the executable file so that you get a UAC prompt each time you run it. You can use a command line Microsoft Manifest Tool to do it but a simpler way is to use Vista UAC Maker which acts as a front end GUI for mt.exe without the need to download the huge Win32 Development Tools. Vista UAC Maker also automatically generates a generic manifest file based on the given project description.
We’ve tested Vista UAC Maker under Windows 10 64-bit and it works perfectly. An important note is that the mt.exe tool requires .NET Framework 3.5 installed in order to work or else Vista UAC Maker will report that it failed to add manifest file to the specified executable file and to make sure that it is not running or being use by another program.
Download Vista UAC Maker
You might also like:
5 Ways to Show Administrator Account on Windows Logon Screen3 Ways to Change a Windows User Account Into an AdministratorPowershell Run Bat File As Administrator Default
Backdoor to Reset Administrator Password or Add New User in Windows 74 Ways to Find Out What Programs are Running in the Windows System Tray6 Ways to Trigger UAC Elevation from Command Line 2 Comments - Write a Comment
I’m hoping to find a powershell script that can check the box on multiple EXE files in a folder which have the “Run this program as an administrator” checkbox. Otherwise, I have to do 98 files manually.
I would not know the command line, especially the correct word to use at the end.
ReplyVery good trick