none
Running a .exe file from the task scheduler on MS Sql Server 2008

    Question

  • Hello, 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

    Monday, May 06, 2013 3:42 PM

Answers

  • You can also get there by Start|Run|secpol.msc then local policies\user rights

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Wednesday, May 08, 2013 1:21 AM

All replies

  • I'd look at the permissions on the program directory versus the user that the task runs with. Also look for errors in

    Event Viewer\Applications\Microsoft\Windows\TaskScheduler\Operational

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Monday, May 06, 2013 4:23 PM
  • Thank you, I took a look at the permissions and it looked good, "Allow" for everyone on all permissions.  I took a look at the errors which are below and one has return code 3 which from what I saw has to do with path of a file which seems weird because if I double click on the .exe everything is fine.  It also runs fine from the Windows PowerShell, but not from the task scheduler.

    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".

    Monday, May 06, 2013 8:37 PM
  • What is the path inside the EXE? How did you arrive at a path problem?

    http://blogs.msdn.com/b/oldnewthing/archive/2011/05/19/10166093.aspx

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Monday, May 06, 2013 9:02 PM
  • I read it here off some website that could be just a matter of opinion: http://www.hiteksoftware.com/knowledge/email/028.htm

    The path inside of the .exe:

    "c:\\PDAutomation\\free_memory.txt";

    The double back slashes are convention for the email class http://www.codeproject.com/Articles/28806/SMTP-Client

    Monday, May 06, 2013 9:08 PM
  • Then I'm guessing its something else. Make sure the task user has logon as a batch job permissions.

    May also need to play around with Security options especially if UAC is enabled.

    http://technet.microsoft.com/en-us/library/cc722152.aspx

     

     

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Monday, May 06, 2013 9:20 PM
  • I got to the "Log on as a batch job Properties" dialog box and I see Administrators, Backup Operators, and Performance Log Users.  If task user is supposed to be in there, I just don't see how to add them, I tried to add task user and even with with capitalized letters and nothing seemed to work.

    I couldn't post a picture of my UAC settings, but here's a google doc with the picture of the UAC settings:

    https://docs.google.com/document/d/14lv2DL0iJ_fjPtnlKmhxc7Q5hgUz1QOeJW8BXs6SZMU/edit?usp=sharing

    Monday, May 06, 2013 11:20 PM
  • Should be like this.

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Monday, May 06, 2013 11:24 PM
  • Depending if its a local or domain user you'll need to change Locations to local machine or domain. Also make sure Users is checked under Object Types

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.


    Monday, May 06, 2013 11:30 PM
  • I can't quote your picture until I have 15 posts, but the picture that has "Logon on as a batch job Properties":

    I cannot find this on the server anywhere.  The info I provided yesterday that matches those 3 is from my local computer, rather than the server. 

    Tuesday, May 07, 2013 3:24 PM
  • The picture with "Locations", I did make a change to match yours but the task scheduler still won't work.
    Tuesday, May 07, 2013 3:25 PM
  • You can also get there by Start|Run|secpol.msc then local policies\user rights

     

     

     


    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

    Wednesday, May 08, 2013 1:21 AM