If you have a .BAT file and you’re trying to get it to run automatically using Task Scheduler in Windows, you might have run into the issue where it simply doesn’t run unless you manually run the task.
Apr 08, 2020 Running batch file on scheduled. To schedule a batch file on Windows 10, you can use the Task Scheduler with these steps: Open Start. Search for Task Scheduler. The source computer is running Windows Server 2008 R2, and the destination machine is running Windows Server 2003 R2. I want to create a batch file that will run on the source computer, and copy all of the files in the D:MICROS folder to a separate network drive. MarketingTeraBytemarketingdataMICROSTESTBKUP is where the files will need. If sufficient temporary disk space is not available Windows Server 2003 cannot complete shadow copy and the backup will skip open files. To use this feature you must use NTFS as file system. Volume Shadow Copy does not mean that you from now on can backup when the server usage is high. I am paranoid so I like to backup files at least once a day, this is how you setup a scheduled task to run a batch file. If you need help writing a batch file, just leave a comment. In Windows NT/2000/XP/2003: 1. Go to the Control Panel, and under Scheduled Tasks, select Add Scheduled Task. When asked what program, select Command Prompt.
I created a batch file that deletes everything inside a temp folder whenever the computer starts up. I created a basic task in Task Scheduler and hoped for the best. Unfortunately, nothing happened when my computer booted up. After a lot of trial and error, I figured out how to get the script to run.
In this article, I’m going to walk you through the settings and permissions you need to adjust in order to get your batch file to run without manual intervention.
Step 1: Check File/Folder Permissions
The first step to fixing this issue is ensuring that the account you are using to run the script in Task Scheduler has Full Control permissions on the folder containing the script, the script itself, and any folders/files that the script touches when it runs.
For example, I created the following batch script below:
I saved the .BAT file to my Documents folder. The path is C:UsersusernameDocuments. I went to C:Usersusername, right-clicked on the Documents folder, and clicked on Properties. Then I clicked on the Security tab.
As you can see, the user account Aseem has been explicitly added and given the Full Control permission. Now you have to do the same thing for the folder that contains the script and for the script itself. Don’t just assume that if you give permissions to the folder containing the script, you’re good to go, because you’re not. Lastly, set permissions on any files and folders that the script will interact with.
In my case, I had to go to C:test, right-click on that folder and add my user account there with Full Control permissions. It’s kind of annoying that you have to do this, but it’s the only way to get the script to run.
Note: The account that is being used to run the script has to be part of the local Administrators group on the computer. In my case, the Aseem account is an administrator account and therefore part of the local Administrators group.
Step 2: Check Task Scheduler Settings
Now let’s go to Task Scheduler and change the appropriate settings there. Open Task Scheduler and find your task under the Active Tasks section. They should be listed out in alphabetical order.
Double-click on it and it’ll open the task by itself in the same window. In order to edit the task, you’ll have to right-click on it and choose Properties.
There are several tabs and a couple of things have to checked and changed here. Firstly, on the General tab, you need to check the user account that is being used to run the task. In my case, it’s the Aseem account, which I had given permissions to earlier on the file system and which is part of the Administrators group on the computer.
Next, you have to choose the Run whether user is logged on or not option and choose Windows Vista, Windows Server 2008 in the Configure for box.
On the Actions tab, you have to select the script, click on Edit and then add in the path to the folder containing the script in the Start in (optional) box. This may seem unnecessary, but it’s not. In my case, I put in C:UsersAseemDocuments in the box.
Now click on OK to save the settings. When you do this, a dialog may appear where you have to enter the password for the user account that will run the task. This brings up another requirement. You can’t use an account that doesn’t have a password. The user account has to have a password in order for the task to run.
Lastly, you should run the task manually once in Task Scheduler to make sure it runs. If it runs fine manually after you changed all the settings, then it should run when it’s supposed to be triggered. In my case, it was supposed to happen on startup and after I made the changes, everything worked fine.
Note that if your script is accessing different computers in a domain when run, you should try to use the domain administrator account to run the task. This will ensure the account has enough permissions to access the remote computers.
Another item to note is if your script accesses resources on a network share. If your script is using letters to access the network, it may not run. For example, instead of using F:data, you should use machinenameshare_namedata in the script. If you still can’t get your script to run, post a comment here and I’ll try to help. Enjoy!
Schedule Server 2003 Backup Batch Files
In this article, we will see how to backup and restore the tasks you have created in Task Scheduler. This will allow you to restore them quickly after reinstalling the operating system. You can also copy them to another PC by doing a backup first. There are several ways to do this, which we will review.
RECOMMENDED: Click here to fix Windows errors and optimize system performance
Task Scheduler is a special tool which comes bundled with all modern versions of Microsoft Windows. It allows the user to schedule the launch of apps, batch files, PowerShell scripts etc after specified time intervals or when certain system events occur. The Task Scheduler has a graphical MMC version (taskschd.msc) which we will use.
If you are not familiar with creation of tasks in Task Scheduler, we have a good tutorial here. Refer to the following article to learn about this topic in detail.
How to backup a scheduled task in Windows 10
To backup a scheduled task in Windows 10, do the following.
- Open Administrative Tools.
- Click the Task Scheduler icon.
- In the Task Scheduler library, find a task you would like to backup. I will backup the task 'Aero Glass'.
- Right click the task and select 'Export' in the context menu. You will be prompted to export the task as an XML file.
- Specify where to store the file and you are done.
Alternatively, you can export the task via the command prompt or PowerShell.
Backup a scheduled task in Windows 10 using Command Prompt
- Open an elevated command prompt.
- Execute the following command:This will export the task named 'Aero Glass' to the c:winaeroaero glass.xml file.
Correct the task name and the file path as you need.
Note: If you have placed your task in some folder in Task Scheduler, don't forget to include the path to the task as follows:
Backup a scheduled task in Windows 10 using PowerShell
- Open a new elevated PowerShell instance.
- Execute the following command:This will export the task named 'Aero Glass' to the c:winaeroaero glass.xml file.
Correct the task name and the file path as needed.
Note: If you have placed your task in some folder in Task Scheduler, don't forget to include the path to the task as follows:
Windows Server Backup Files
How to restore a scheduled task in Windows 10
To restore a scheduled task from backup in Windows 10, do the following.
- Open Administrative Tools.
- Click the Task Scheduler icon.
- In the Task Scheduler library, click the action 'Import Task...' on the right.
- Browse for your XML file and you are done.
Restore a scheduled task in Windows 10 using Command Prompt
- Open an elevated command prompt.
- Execute the following command:This will restore the task named 'Aero Glass' from the c:winaeroaero glass.xml file.
Correct the task name and the file path as you need.
Restore a scheduled task in Windows 10 using PowerShell
- Open a new elevated PowerShell instance.
- Execute the following command:This will export the task named 'Aero Glass' from the c:winaeroaero glass.xml file.
Correct the task name and the file path as you need.
![Windows Windows](/uploads/1/2/7/7/127774927/666906261.png)
Note: If you are going to restore the task on a different computer with different login credentials, you might need to edit the XML file and change the user name (and password) to match the target OS.
That's it.
RECOMMENDED: Click here to fix Windows errors and optimize system performance