.bat file doesn't run when started from task scheduler

I have set up a .bat file to open an excel workbook that I need to run at 1:00 AM.  The file is a .xlsm that I am using to generate a report.  I can run the excel file manually and it works.  I created a .vbs file to start the .xlsm file, and it works.  I created a .bat file to run the .vbs file and it works as well.  When I try to run the .bat file from a scheduled task, I can see the task status show running and then completed, but the report is not generated.  I am not sure what the problem could be.

This is the .bat file.

@echo off
cscript "C:\REP_Reports\Report Design\vbScripts\vbsMRT.vbs"

This is vbsMRT.vbs.

option explicit
on error resume next
Dim objExcel
Dim objWorkbook
Dim MyFile
Set objExcel = CreateObject("EXCEL.APPLICATION")
objExcel.visible = true
Set objWorkbook = objExcel.Workbooks.Open("C:\REP_Reports\Report Design\2MARYMO_MRT01R01.xlsm")
Set objWorkbook = Nothing
Set objExcel = Nothing
Aaron GreeneProgrammerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITCommented:
What does your Action look like? Per your post, it should be...

Program/script: cmd
Add arguments: /c c:\folder\file.bat

Try playing with the task General, Security Options:
- "Run only when user is logged on", or "Run whether user is logged on or not".
- Also, set "Run with highest privleges"
0
Bill PrewCommented:
For debugging you can try the following as well:

Program/script: cmd
Add arguments: /c c:\folder\file.bat>"C:\REP_Reports\Report Design\vbScripts\vbsMRT.log" 2>&1

Also remove the "on error resume next" in the VBS script.

Then after you try and run it from the task scheduler check the LOG file for any errors.

~bp
0
Aaron GreeneProgrammerAuthor Commented:
I tried all of your suggestions, and go the same results, nothing.  I deleted my existing task and decided to start over, but this time I used the Create basic task option.  After setting things up, I set it to run on a time schedule.  The task successfully ran.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Bill PrewCommented:
Sounds like something was set in the first task that was causing the problem.  Can't really say what that might have been at this point, but glad that recreating it resolved the problem for you, well done.

~bp
0
Aaron GreeneProgrammerAuthor Commented:
Do you know what the difference is between the "Create Task" and "Create Basic Task" options?  Once the task is created, the properties screens are identical.
0
Bill PrewCommented:
Conceptually the difference is just the complexity of the process.  The "Basic" approach uses more of a wizard type approach, leading the user through a simpler set of steps and questions.  The "create task" method takes you right to the screens involved and you have to know a bit more about what you need to enter.

The end result is the same, a scheduled task is added to the system.  But there may be some differences since the basic approach probably defaults some settings that non-basic approach allows the user to change during initial task creation.

~bp
0
Aaron GreeneProgrammerAuthor Commented:
I still don't know what caused the problem.  I'm chalking that up to user error.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.