[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

windows 7 task schedule

Posted on 2014-12-31
7
Medium Priority
?
180 Views
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.
0
Comment
Question by:JeffBeall
[X]
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
7 Comments
 
LVL 25

Expert Comment

by:NVIT
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?
0
 
LVL 1

Author Comment

by:JeffBeall
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
0
 
LVL 25

Assisted Solution

by:NVIT
NVIT earned 1000 total points
ID: 40526098
Also, set "Run with highest privileges"
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 85

Expert Comment

by:oBdA
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.
0
 
LVL 1

Author Comment

by:JeffBeall
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
pause

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

Accepted Solution

by:
oBdA earned 1000 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.
0
 
LVL 1

Author Closing Comment

by:JeffBeall
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
pause

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!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

656 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