Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scheduled task erroring out.

Status
Not open for further replies.

Sam8932

Programmer
Oct 15, 2002
22
0
0
I have a scheduled task set up to run a .bat file that starts a macro in an
Access DB. The DB pulls down files from an SFTP server and then loads them
to a table. I then export them to an excel file and save that file to a .csv
file to be loaded to another SFTP server. When I run the .bat file it works
fine. When I try running it from the scheduled task (set up under the same
user name I'm running the .bat file with) it errors out when it tries saving
the .xls file to a .csv file. I get a "Permission denied" error.

.bat file:
"C:\Program Files\Microsoft Office\OFFICE11\msaccess.exe" "C:\SendCDBRecsToDW\
Compile_Files.mdb" /x Compile_Data

Code that is erroring out:
Set wb = xlApp.Workbooks.Open(strFilePath & strFileNameExtract)
---> wb.SaveAs strFilePath & strFileNameUpload, FileFormat:=xlCSV
wb.Close False

It creates the .xls file but errors out when saving it to a .csv file. It
seems like Access can't properly launch the Excel object when Access is being
launched from the scheduled task.

I'm stumped and would appreciate any help I can get on this. I need to get
this figured out ASAP!

Thank you in advance.
 
Sounds like a permission problem. Are you logged in when the scheduled task runs? I have not played much with schedluled tasks but can you run as a user or yourself so that has more permissions?
 
No I am not logged in when it runs. The account I have the scheduled task set up under has administrative privileges.
 
If you log in as the user with administrative privileges and run the bat file, does it work? Are there any drive mappings that do not exist that exist when you are logged in that are relevant?
 
lameid, thank you for the responses. Yes the bat file works. No drive mappings are being used. All files are put on the same directory that the DB resides on.

 
Hmmm... Did you try the scheduled task after running as the logged in user? If it is profile related it may work if it had to create one.
 
Yep we tried that. For now we've created a work around where we bypass creating the excel file. It works fine this way but it's still confusing as to what's going on. One thing I should have mentioned in the beginning is that this app ran fine with the same scheduled task until the server was moved to a different location.
 
I'd talk to the people that moved it and find out everything security related that changed. There must be something there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top