Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Running a .exe file from the task scheduler

Author  Topic 

b.fleckenstein
Starting Member

6 Posts

Posted - 2013-05-06 : 11:53:57
Hello, not sure if I'm in the right place for this question, but...

I am trying to get a program to run on a windows server utilizing its integrated task scheduler. It works fine if I just double-click on the .exe file, but not when the scheduler tries to run it:

The program has the following steps: creates or overwrites a .txt file and stores it in the same subdirectory as the .exe file, then uses that .txt file as an attachment in sending an email. However, in running the program with the scheduler, I noticed it doesn’t create a new .txt file, the copy of .txt file that is sent via email is the existing file and doesn’t overwrite a new .txt file.

If I delete the old .txt file and invoke the .exe file using the scheduler, the .exe file will not create a new .txt file. As expected: if I put an old .txt file there, the email will send no problem attaching that old file, but the program won’t overwrite it with a new file.

I have done a chmod a+x on the .exe file and its permission level is: –rwxr-xr-x

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-05-06 : 14:22:05
Log into the database server with the same account used for the SQL Server service (or the agent if they are different). Then run the exe from a cmd window. Does it work as expected there?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

b.fleckenstein
Starting Member

6 Posts

Posted - 2013-05-06 : 14:45:53
I was able to run it through Windows PowerShell. From the shell, it ran as it is supposed to.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2013-05-06 : 15:19:32
Cool, glad you got it working.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

b.fleckenstein
Starting Member

6 Posts

Posted - 2013-05-06 : 16:07:15
I wish, the problem is it doesn't run through the task scheduler.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-07 : 04:02:51
does you have any logging mechanism for exe? have you checked logs for error message?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2013-05-07 : 11:24:00
quote:
Originally posted by b.fleckenstein

I wish, the problem is it doesn't run through the task scheduler.


Are you using the windows task scheduler? Make sure the account you set to run it has permissions to do so, and on everything the exe touches.
Go to Top of Page

b.fleckenstein
Starting Member

6 Posts

Posted - 2013-05-07 : 11:29:05
Here's a look at the error messages. There is one that is a return of 3, but from what I understand that could be multiple things:
http://blogs.msdn.com/b/oldnewthing/archive/2011/05/19/10166093.aspx


Task Completed:

Task Scheduler successfully finished "{eb26d7a0-6101-4aed-b9c5-a45195742364}" instance of the "\PDAutomation" task for user "OLYMPUS\fleckenstein".

Action Completed:

Task Scheduler successfully completed task "\PDAutomation" , instance "{eb26d7a0-6101-4aed-b9c5-a45195742364}" , action "C:\PDAutomation\CSmtp_prac.exe" with return code 3.

Created Task Process:

Task Scheduler launch task "\PDAutomation" , instance "C:\PDAutomation\CSmtp_prac.exe" with process ID 4876.

Action started:

Task Scheduler launched action "C:\PDAutomation\CSmtp_prac.exe" in instance "{eb26d7a0-6101-4aed-b9c5-a45195742364}" of task "\PDAutomation".

Task Started:

Task Scheduler started "{eb26d7a0-6101-4aed-b9c5-a45195742364}" instance of the "\PDAutomation" task for user "OLYMPUS\fleckenstein".

quote:
Originally posted by visakh16

does you have any logging mechanism for exe? have you checked logs for error message?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


Go to Top of Page

b.fleckenstein
Starting Member

6 Posts

Posted - 2013-05-07 : 11:30:30
Logging mechanism? I'm not too savvy with this stuff, so not sure what you're talking about.

quote:
Originally posted by visakh16

does you have any logging mechanism for exe? have you checked logs for error message?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs


Go to Top of Page

b.fleckenstein
Starting Member

6 Posts

Posted - 2013-05-07 : 11:35:55

Permissions for everyone is set to allow.
I can't post a pic, but here's a google doc with what I'm seeing:
https://docs.google.com/document/d/14lv2DL0iJ_fjPtnlKmhxc7Q5hgUz1QOeJW8BXs6SZMU/edit

quote:
Originally posted by russell

quote:
Originally posted by b.fleckenstein

I wish, the problem is it doesn't run through the task scheduler.


Are you using the windows task scheduler? Make sure the account you set to run it has permissions to do so, and on everything the exe touches.



Go to Top of Page
   

- Advertisement -