0

I am trying to run a scheduled task with SYSTEM Account (NT Authority\SYSTEM). This scheduled task is running an exe file (Exe file is for .NET application with 3.5 framework, built in vb.NET to perform some task.) This scheduled task is set to - 1. Run once a day 2. Option selected as "Run with highest privileges" 3. In Action tab both values Program/script and Start in (optional) are filled.

When the task runs at specified time it shows that "Task Scheduler successfully completed task "Task Name" , instance "{Guid}" , action "exe file path" with return code 0." in History tab. But exe file is not getting executed as i cannot see any expected results.

When i am setting the Run As Field to my credentials in scheduled task, the task is working and is able to able to run the exe file properly.

But i need to use SYSTEM account to run the scheduled task.

Can anybody here please let me know what i needs to make this scheduled task work properly.

bhanu
  • 208
  • 1
  • 5
  • 15
  • You need to use SYSTEM to run the task... why? Windows is getting more and more careful with permissions and security, so making a scheduled task that runs outside of an user session is getting trickier all the time (it's a huge security hole). Also, it sounds that your application hide errors - make sure your error handling actually reports issues (e.g. to event log). – Luaan May 23 '16 at 09:49

1 Answers1

2

"But exe file is not getting executed as i cannot see any expected results" indicates strongly that you dont know whether or not your code IS getting executed - you just THINK its not getting executed because it doesnt work as you expect.

Almost certainly your code is trying to access resources which the SYSTEM account doesnt have permission for. This link RunAs A different user when debugging in Visual Studio shows you how to run your program in VS.net and allow debugging when acting as a different user. It should allow you to debug your application properly and find out how it works under the SYSTEM user account.

Community
  • 1
  • 1
PhillipH
  • 6,182
  • 1
  • 15
  • 25
  • Hi Philips, Thanks for your comments, but SYSTEM account (NT Authority\SYSTEM) does not have any password, how can i open visual studio with SYSTEM account as on clicking Run as different user it asks for username/ password – bhanu May 23 '16 at 12:25
  • This post explains http://stackoverflow.com/questions/21466060/how-to-debug-as-nt-authority-system-in-visual-studio – PhillipH May 23 '16 at 12:59
  • Another option is to launch the application as usual and then use "Attach to Process" to attach the debugger to the process. (Of course you'd need to add a delay when the application starts up, or it will exit before you get a chance to attach the debugger.) – Harry Johnston May 24 '16 at 02:42
  • It's relatively uncommon to run across resources (files, registry entries, etc.) that SYSTEM doesn't have access to but an administrative user does. (Keeping in mind that the local system token includes the Administrators group.) There's more likely to be a dependency on something SYSTEM doesn't have, e.g., there's a lot of user configuration settings that don't get created until the first time Explorer starts up. (Either way, though, you're going to want a debugger. +1.) – Harry Johnston May 24 '16 at 02:48
  • Thanks everyone for your comments. I tried to run the scheduled task with service account that has username and password. Then I opened visual with that service account and found the error that sql server was not accessible from the system account and service account. So I got the issue and on the way to fix it. – bhanu May 26 '16 at 16:24