windows 7 task schedule

Posted on 2014-12-31
Last Modified: 2015-01-02
Is there a trick to getting win7 to schedule AND run a task? I created a simply Batch file that I would like to run each night at around 10pm. To test, I setup a task in the task scheduler, and have it set to run daily at about 5 mintes from when I created the task. It complained that I need to be a part of the batch job rights group. So I opened secpol.msc, went to Local Policies, User Rights Assignment, and added my account to "Log on as a batch job".
Now it doesn't complain when I schedule the task, and even looks like it runs because I go to the properties of the task, and look at the history tab
It just has a lot information events, one of them, in the task category column has, "Task Started". Then above that, "Action started" and in the general tab it has "task scheduler launched action "C:\test\test.bat" in instance ... which is my test batch file. I know it doesn't work because this batch just copies a file from one local location to a network share, but the file isn't there when I look in the folder on the share.
I know the batch file works because I run it manually and it works fine.
So, any ideas what I am missing.
Question by:JeffBeall
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 24

Expert Comment

ID: 40525971
Not sure if this help but... for the task, under General, Security Options, what user account is set? That account should have rights to the target folder.
Also, what Run... button is set?

Author Comment

ID: 40526090
under general, security options my user account is used

the "Run whether user is logged on or not" is checked, and the "Do not store password" box is not checked
LVL 24

Assisted Solution

NVIT earned 250 total points
ID: 40526098
Also, set "Run with highest privileges"
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

LVL 85

Expert Comment

ID: 40526687
Please post your script. It's probably copying a file from C:\test, using something like "copy test.txt \\server\share\folder".
This works when you double-click the script, because the working directory will be set to the script's folder, but when a script is started using the task scheduler, the working directory will be "%Systemroot%\system32", not the script's folder.
To test, simply open a command prompt, enter "cd /d %%Systemroot%\system32%", then run your script from this prompt as C:\test\test.bat. If it errors out, the working directory is the issue.
To reference the script's folder, independently of the working directory, use %~dp0; note that this already has a trailing backslash at the end.

Author Comment

ID: 40528127
oBdA, I tried doing what you suggested

"To test, simply open a command prompt, enter "cd /d %%Systemroot%\system32%", then run your script"

and the script ran fine. So I thought I would put my batch in C:\windows\system32 because, like you said

" when a script is started using the task scheduler, the working directory will be "%Systemroot%\system32"

but that didn't work either.

I opened the task scheduler as admin and scheduled the batch as admin, wondering if it's a permissions thing, but that didn't work either. Also, in the task scheduler, if I click on the task and choose run, nothing happens
By the way, the batch looks like this.

taskkill /IM OUTLOOK.EXE
choice /N /d y /t 5
robocopy "C:\outlook" "H:\test" /is /FFT /XO /E /PURGE

if I manually run this by double clicking on the batch file, it works every time.
Any ideas?
LVL 85

Accepted Solution

oBdA earned 250 total points
ID: 40528142
Replace "H:\test" with the UNC ("\\server\share\test"), and remove the "pause"; when run as a task, nobody will be able to press a key.

Author Closing Comment

ID: 40528438
ok, my batch looks like this now

taskkill /IM OUTLOOK.EXE
choice /N /d y /t 5
robocopy "C:\outlook" "\\DFS001\D01BEAJE02\test" /is /FFT /XO /E /PURGE

I kept the pause to see if it runs ok, once this works, I will remove it.
And it looks like it is working! I think I had to open the task manager as my own account, not the admin, however, before I changed the script per your instructions to the UNC it didn't work if I ran the task manager with my account, or the admin account.

Thank you for the help!

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
When you try to extract and to view the contents of a Microsoft Update Standalone Package (MSU) for Windows Vista, you cannot extract the files from the MSU. Here we are going to explain how to extract those hotfix details without using any third pa…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question