0

I want to create a scheduler in Windows through c# code. I want the scheduler to run even if system is power off or even if user is not logged in.

I have tried following:

  • SCHTASKS: /Create /TN "New Task" /SC HOURLY /TR blah.exe /RU Test - creates a task but not run when user is not logged in

  • SCHTASKS /Create /TN "New Task" /SC HOURLY /TR blah.exe /RU System - gives Access denied error

  • SCHTASKS /Create /TN "New Task" /SC HOURLY /TR blah.exe /RU Administrator - gives Access denied error

  • SCHTASKS /Create /TN "New Task" /SC HOURLY /TR blah.exe /RU usernameofsystem /RP passwordforthatuser - gives Access denied error

I also see related posts on StackOverflow but didn't find any suitable answer which will work for me.

Stephen Byrne
  • 7,400
  • 1
  • 31
  • 51
  • Just guessing but do subsequent attempts to create fail because you already have a scheduled task called 'New Task'? – James Lucas May 06 '15 at 08:05
  • Tempted to flag this as a duplicate of [this](http://stackoverflow.com/questions/11190405/how-to-schedule-a-task-wether-the-user-is-logged-on-or-not-in-powershell). The usage of C# is irrelevant, since the "problem" lies with the task scheduler. – BCdotWEB May 06 '15 at 08:09
  • I have tried the link you are specifying but it is giving error "SCHTASKS /Create /TN "New Task" /SC HOURLY /TR blah.exe /RU System" error is Access denied – Shalini Vashist May 06 '15 at 10:06

0 Answers0