Open any .BAT as administrator with these tricks

Despite this, sometimes it is possible that even though we have a .bat file that will be in charge of doing everything we want, we run into problems when executing it. And it is that there are occasions where certain commands require us of administrative permissions for their execution. Therefore, it is important to know how to run a batch file as an administrator in Windows 10 and Windows 11.

What is a BAT file

When we talk about a file with a .bat extension we will be referring to documents of batch processing. They are text files that include a series of commands that are used to perform tasks when executing repetitive tasks or a succession of actions one after another. These files are used by programs to perform various tasks such as copying, deleting files, running applications or ending certain processes.

These files are generally part of the operating system. On DOS systems, the batch file contains the extension .bat, the most popular being AUTOEXEC.BAT that runs at system startup.

How to create them

Creating a batch file is a simple task for which you only need a text editor that allows us to create small plain text scripts, such as Notepad itself. Once opened, we proceed to write the orders of the BAT file that we are going to create. To do this, we must take into account that each action is placed on different lines, so that, if we have 3 actions, we must create 3 lines.

Once we have finished creating the code, we can save the file from the “Save as” section of the text editor. Here we will write the name of the file and make sure to change its extension .txt to the extension .bat and selecting in the “Type” section the option “All files”.

Open files

These types of files are composed of commands written in text, so we can open them with any editor as well as to create them. Windows has its own editor that includes by default, such as the memo pad. To do this, it will only be necessary to click with the right button of the mouse on the file. This will make a contextual menu appear where we must choose the “Edit” option. In the more advanced editors we can find the syntax highlighting function, an extremely useful function when editing these types of files.

Run a batch file as administrator

If we need to be able to run a BAT or batch file as an administrator in Windows 10 or Windows 11, we have three ways to do it. One from File Explorer, another using Command Prompt or Task Scheduler. Next, we are going to see how we can do it using each of these options.

From File Explorer

When trying to open a batch file as administrator, the first thing that comes to mind is to access its properties to try to mark the option to Run as administrator. To do this, right click on the file and click on “Run as administrator”. This will mean that whenever we want to run it as administrator we will have to do this. Likewise, we can also automate this process so that whenever we execute it, it is launched with administrator permissions.

In this case, what we must do is click with the right mouse button on the desired file and within the contextual menu we select the option “Create shortcut”. Then we right-click on the shortcut that we have created and select the “Properties” option.

In the new window that appears, click on the “Direct Access” tab and click on the “Advanced Properties” section. Within the Advanced Properties, we check the box “Execute as an administrator” and we click OK. Finally, we click Apply to save the changes and OK to close the Properties.

Run shortcut as administrator

From this moment on, every time we run the file from the shortcut by double clicking on it, the Windows UAC message will appear that we must accept to run it as administrator. Having configured from the properties that it is run as administrator, we will no longer have to do anything manually, since whenever we execute it from the direct access it will be executed with administrator permissions.

Using Command Prompt

Another method to be able to run batch files with administrator rights is by using the Command Prompt. Also known as CMD, it is a way to perform advanced actions in Windows using text commands. In this way we can write commands and execute them. It is very useful for automating tasks using scripts and batch files, or performing advanced administrative tasks and even troubleshooting the operating system.

Run bat file from Command Prompt

To execute it we write cmd in the search box of the Start menu. Once located, click on “Run as administrator”. In this way, the Command Prompt will open elevated privileges, so we only have to write the path and the name of the batch file that we want to execute and press Enter. This way we can use a batch file instead of writing a script to run a task.

With Task Scheduler

We can also run a batch file as administrator in Windows 10 and Windows 11 from Task Scheduler. It is a component of the Microsoft operating system that offers us the ability to schedule the start of programs or scripts at specified times or after specified time intervals.

To carry out this work, we write task scheduler in the search box of the Start menu and execute it. Now we must open a new folder, for which we right-click on the “Task Scheduler Library” section and select “New folder”. We write the name and click “OK”.

New folder task scheduler

This new folder that we have created will appear as a subfolder within the Library section of the Task Scheduler. Now we right-click on the created folder and select the option to «Create basic task». This will make a new window appear where we must write a name and a description for the type of task that we are going to program.

Scheduler create basic task

We click on «Next» and we indicate when we want the task to start (daily, weekly, monthly, etc). We select the task topo and within the »Start a program» section, click on the «Examine» button to enter the path where the batch file is located and click «Finish».

Select BAT file with task scheduler

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *