To perform various actions on Windows 10, you can simply use batch files with Command Prompt. While writing commands on your system for DOS or Windows, you need to retype a lot of them in order to run commands. Batch files store the commands in a serial so as to run and executed in the same line-up. The command-line interpreter takes the input from the batch file and executes it in the same order. While there are many ways to run the batch file as Administrator on Windows 10, we discuss them in this article. Let’s begin with an overview of batch files.
- Run Bat As Administrator From Powershell
- Run Bat As Administrator At Log In W10
- Run Bat File As Administrator
- Run Bat As Administrator Windows 10
- Run Bat As Administrator Not Working
What Is A Batch File?
Batch file is a script file which consists of a series of commands in plain text for executing in the command line interpreter. It was required to make the work easy for users to save the often-used commands. When the batch file is run, the commands are executed line by line. Batch file is in the form of .bat,.cmd,.btm file extensions. You can find it saved in the simple text form on the Notepad or another text editor.
Simple commands for batch files will be:
echo- Prints input string.
cls- Clears command Window.
pause- Stop the batch file execution.
When we run the batch file from the command prompt (running as administrator), the batch file runs successfully on all above combinations. Success means the word doc is converted to HTML format successfully. When we run the batch file using the task scheduler, it fails on combination #4.
- The batch file doesnt run as admin and based on my research it can't auto run as admin. My idea is to move the program install batch script to a separate folder and create a new batch script for the startup folder that will force the original batch file to run as administrator.
- @AnsgarWiechers - in his own words, I am searching for an alternative for running a batch file by right clicking on it and running as an administrator. I want to automate it from another batch file. if he is able to run it by right clicking and run as administrator, then he already knows the admin password - this is like sudo on linux.
title- Changes the prompt window title.
exit- Exit the command prompt.
copy- Copies a file/files.
::- Add a comment in the batch file.
There are different types of batch files available.
- INI – Initialization file is the set of default variables for Windows programs. It is denoted by *.ini
- SYS – System files are denoted by *.sys and it may be modified.
- COM – Commands files are denoted by *.com and are the executable files for DOS.
- CFG – Configuration files are denoted by *cfg.
- CMD – Used in Windows New Technology operating systems (32 bit).
How to create a batch file?
To proceed, all you need is any text editor on your system with knowledge of command prompt. Follow the steps below to create a batch file. In the following method, we make use of a notepad to create a batch file.
Step 1: Open the Start Menu and type Notepad in the search bar.
Step 2: Open Notepad.
Step 3: Type the following –
@ECHO OFF
ECHO Your first Batch File.
PAUSE.
Here we are trying to run a batch file with the result which says – Your first batch file.
Step 4: Click on File from the menu, and click on Save from the drop-down options.
Step 5: Save the file name with .bat file extension name. For eg: First_batch_file.bat
Run Batch File As Administrator On Windows 10
There are many ways to run batch file as administrator on Windows 10. It can be executed by file explorer, command prompt and task scheduler.
1. Run batch file as administrator on Windows 10 using File explorer-
This is one of the methods to run batch file on demand. Open File Explorer and locate the folder with the saved batch file. To run the batch file as administrator on Windows 10 with the help of file explorer right-click on it. The properties show you the option to Run as Administrator.
Click Yes on the confirmation dialogue box. It is one of the simplest methods to run batch file without command prompt.
2. Run batch file as administrator on Windows 10 using Command Prompt-
It is another of the method to run batch file as administrator on Windows 10 with command prompt. Follow the steps given below:
Step 1: Open the Start Menu and type command prompt on the search bar.
Step 2: Select Command Prompt and then on the right-side panel click on Run as Administrator.
Step 3: The command prompt opens with the title Administrator: Command Prompt.
Type the batch file path and name and press Enter.
It is how you can use batch file instead of typing the commands here to execute a task. To run command on command prompt by simply adding a batch file which consists of script.
Run Bat As Administrator From Powershell
3. Run batch file as administrator on Windows 10 using Task Scheduler-
Another method to run batch file as administrator on Windows 10 which will schedule a task. The following steps will make you schedule a task by a batch file.
Step 1: Open the Start menu and type Task Scheduler.
Step 2: Open Task Scheduler from the results.
Step 3: To open a new folder, right-click on the Scheduler library. Type a name for your folder and click on OK.
Step 4: On the left panel, right-click on the newly saved folder. Select the Create Basic Task.
Step 5: Give the name and description of the type of scheduled task. Click Next, and select when do you want the task to start off – Daily, weekly, monthly etc.
Run Bat As Administrator At Log In W10
Step 6: Select the type of the task, and in the Start, a Program section of Action Centre, enter the batch file path from the browser option. And click on Finish.
Wrapping Up:
This is how you can run batch file as administrator on Windows 10. It included the most commonly used method of using a command prompt to run batch file as administrator. Along with the task scheduler and file explorer which are other methods to run batch file without prompt on Windows 10.
We Love To Hear From You
Please tell us your views on this post in the comments section below. Also, leave your views and queries in the comments section below. We would love to get back to you with a solution. We post regularly on the tips and tricks along with solutions to common issues related to technology. Subscribe to our newsletter to get regular updates on the tech world. Follow us on Facebook, Twitter, LinkedIn, and YouTube and share our articles.
Responses
Runas is a very useful command on Windows OS. This command enables one to run a command in the context of another user account. One example scenario where this could be useful is: Suppose you have both a normal user account and an administrator account on a computer and currently you are logged in as normal user account. Now you want to install some software on the computer, but as you do not have admin privileges you can’t install the same from the current account. One option is to switch user and login as administrator. Instead, you can do the same by simply using runas command. You just need to launch the installer from command prompt using runas command and by providing administrator login id and password.
Let’s see the syntax of runas command with some examples.
Run a program from another user account
The command to launch a program using another user credentials is given below.
For example, if you want to open registry editor as administrator of the computer, the command would be as below.
After running the above command, you will be asked to enter the password of administrator account. After password validation, registry editor will be opened with the administrator account credentials.
To specify arguments to the program:
If you need to provide arguments to the program that need to be invoked as another user, you can put the program name and the parameters in double quotes.
For example to open the file C:boot.ini as administrator, the command would be:
Running command prompt as another user :
If you have multiple commands need to be executed with administrator(or any other user )credentials, instead of running each command using runas, you can open command prompt window once as the administrator and then run all the commands in that window. Below is the command for opening a command window using runas.
Example:
It will launch new command window after printing the above message.
Run a batch file as administrator
Run Bat File As Administrator
To run a batch file as administrator of the computer, you need to mention the path of the batch file in the place of command in the runas syntax.
For example, to run the batch file located at c:datamybatchfile.bat, you need to run the below command.
Run Bat As Administrator Windows 10
Some questions regarding runas command:
When I use runas command, I am getting the error ‘This program is blocked by group policy. For more information, contact your system administrator’. How can I fix this?
Administrator of your system might have disabled users to login from command prompt. In group policy editor, this setting can be found in the below node.
Computer Configuration -> Windows settings -> Security settings ->Local Policies -> User rights assignment
Run Bat As Administrator Not Working
In the above path, look for the setting ‘Deny logon as a batch job‘. If you have administrator privileges, you can disable this settings. Otherwise, you need to contact the system/domain administrator.