In case you have a .BAT file and also you’re making an attempt to get it to run routinely utilizing Activity Scheduler in Home windows, you may need run into the problem the place it merely doesn’t run until you manually run the duty.
I created a batch file that deletes every part inside a temp folder every time the pc begins up. I created a fundamental activity in Activity Scheduler and hoped for the very best. Sadly, nothing occurred when my laptop booted up. After quite a lot of trial and error, I discovered the way to get the script to run.
On this article, I’m going to stroll you thru the settings and permissions it is advisable to modify so as to get your batch file to run with out guide intervention.
Step 1: Test File/Folder Permissions
Step one to fixing this problem is making certain that the account you’re utilizing to run the script in Activity Scheduler has Full Management permissions on the folder containing the script, the script itself, and any folders/information that the script touches when it runs.
For instance, I created the next batch script under:
cd /d %folder%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q)
I saved the .BAT file to my Paperwork folder. The trail is C:UsersusernameDocuments. I went to C:Usersusername, right-clicked on the Paperwork folder, and clicked on Properties. Then I clicked on the Safety tab.
As you’ll be able to see, the consumer account Aseem has been explicitly added and given the Full Management permission. Now you need to do the identical factor for the folder that comprises the script and for the script itself. Don’t simply assume that if you happen to give permissions to the folder containing the script, you’re good to go, since you’re not. Lastly, set permissions on any information and folders that the script will work together with.
In my case, I needed to go to C:check, right-click on that folder and add my consumer account there with Full Management permissions. It’s type of annoying that you need to do that, but it surely’s the one method to get the script to run.
Be aware: The account that’s getting used to run the script needs to be a part of the native Directors group on the pc. In my case, the Aseem account is an administrator account and due to this fact a part of the native Directors group.
Step 2: Test Activity Scheduler Settings
Now let’s go to Activity Scheduler and alter the suitable settings there. Open Activity Scheduler and discover your activity underneath the Energetic Duties part. They need to be listed out in alphabetical order.
Double-click on it and it’ll open the duty by itself in the identical window. As a way to edit the duty, you’ll need to right-click on it and select Properties.
There are a number of tabs and a few issues need to checked and altered right here. Firstly, on the Common tab, it is advisable to test the consumer account that’s getting used to run the duty. In my case, it’s the Aseem account, which I had given permissions to earlier on the file system and which is a part of the Directors group on the pc.
Subsequent, you need to select the Run whether or not consumer is logged on or not possibility and select Home windows Vista, Home windows Server 2008 within the Configure for field.
On the Actions tab, you need to choose the script, click on on Edit after which add within the path to the folder containing the script in the Begin in (elective) field. This may increasingly appear pointless, but it surely’s not. In my case, I put in C:UsersAseemDocuments within the field.
Now click on on OK to avoid wasting the settings. Once you do that, a dialog might seem the place you need to enter the password for the consumer account that can run the duty. This brings up one other requirement. You may’t use an account that doesn’t have a password. The consumer account has to have a password to ensure that the duty to run.
Lastly, it’s best to run the duty manually as soon as in Activity Scheduler to verify it runs. If it runs wonderful manually after you modified all of the settings, then it ought to run when it’s presupposed to be triggered. In my case, it was presupposed to occur on startup and after I made the modifications, every part labored wonderful.
Be aware that in case your script is accessing totally different computer systems in a site when run, it’s best to attempt to use the area administrator account to run the duty. This can make sure the account has sufficient permissions to entry the distant computer systems.
One other merchandise to notice is that if your script accesses assets on a community share. In case your script is utilizing letters to entry the community, it could not run. For instance, as an alternative of utilizing F:knowledge, it’s best to use machinenameshare_namedata within the script. If you happen to nonetheless can’t get your script to run, put up a remark right here and I’ll attempt to assist. Take pleasure in!