SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Other SQL Server 2008 Topics
 Running a .exe file from the task scheduler
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

b.fleckenstein
Starting Member

6 Posts

Posted - 05/06/2013 :  11:53:57  Show Profile  Reply with Quote
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

Edited by - b.fleckenstein on 05/06/2013 11:54:26

tkizer
Almighty SQL Goddess

USA
37274 Posts

Posted - 05/06/2013 :  14:22:05  Show Profile  Visit tkizer's Homepage  Reply with Quote
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 - 05/06/2013 :  14:45:53  Show Profile  Reply with Quote
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

USA
37274 Posts

Posted - 05/06/2013 :  15:19:32  Show Profile  Visit tkizer's Homepage  Reply with Quote
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 - 05/06/2013 :  16:07:15  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 05/07/2013 :  04:02:51  Show Profile  Reply with Quote
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

USA
5072 Posts

Posted - 05/07/2013 :  11:24:00  Show Profile  Visit russell's Homepage  Reply with Quote
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 - 05/07/2013 :  11:29:05  Show Profile  Reply with Quote
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 - 05/07/2013 :  11:30:30  Show Profile  Reply with Quote
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 - 05/07/2013 :  11:35:55  Show Profile  Reply with Quote

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.




Edited by - b.fleckenstein on 05/07/2013 11:37:40
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000