1

Problem:

I have a .bat to send me an email with an attachment. When I execute it in cmd or in Windows Explorer, it works and I receive my email within 3-5 sec. I scheduled a task for its execution daily, but when the trigger occurs, the only thing I can see is a black window popping up called tasksend or something like that and that's it. When I check the task scheduler for my task, it is tagged as executed successfully. No error messages. Yet, I don't have my Email.

System Configuration:

E528-2821 Windows 7 32-bit

What I tried:

It suggested to:

  1. check the tick box [Run with highest Privileges]
  2. adding the scheduled task in the Startup folder
  3. check the tick box [Run only when user is logged on]
  4. setting the Start In path manually (under the Action properties)
  5. In addition to 4, using a path that did not contain spaces

None of them worked.

It suggested to change something about the Local Group Policy. However the Local Group Policy Editor feature is not included in the Windows 7 Starter, Home Basic, and Home Premium editions.

This is an alternative to Windows Task Scheduler I downloaded, but it gives me the same problem.

4
  • Looks like a duplicate of .bat runs from command line but not when scheduled; unfortunately, that hasn’t been answered after almost two months. Aug 3, 2013 at 20:53
  • its a batch, it shows running somewhat, and probably does not have permission, or is being blocked from the action. A possible way to disagnose how it runs different when run from the scheduler, you could toss some error control and logging into the batch. simple things like appended echos creating a log.txt. and having IF error stuff put in. The person who designed the bat, could assist in providing user notifications, instead of just a blinking away window.
    – Psycogeek
    Aug 3, 2013 at 22:58
  • Yes good suggestion. I had done the log.txt and figured out what went wrong. Thanks you.
    – Khalil
    Aug 3, 2013 at 23:18
  • So? What was it that went wrong?
    – klokop
    Jul 24, 2015 at 8:25

2 Answers 2

3

As @psycogeek suggested, I made the scheduled task spawn out the execution of the bat file to a log.txt file. I did this by adding > log.txt in the parameter field of the scheduled task.

Apparently, the difference between a manual launch and a scheduled launch was that blat didn't remember its configuration. As such, I had to add in the .bat file before the execution of blat, blat -install again with all its parameters.

1

Probably when you run it yourself it's executing under your windows identity and working because of your profile settings or privileges. When you run a scheduled task it normally runs as local system account and this doesn't have access to your settings, so doesn't work.

Try changing the scheduled task to run as you. You'll need to enter your username and password.

If that doesn't work it's likely something to do with it running in the background / unattended. Does the .bat require any user input? Can you provide more detail of what's in the bat file?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .