dahall / TaskScheduler

Provides a .NET wrapper for the Windows Task Scheduler. It aggregates the multiple versions, provides an editor and allows for localization.
MIT License
1.2k stars 191 forks source link

Replicating command line functionality in TaskScheduler wrapper (user account=INTERACTIVE) #952

Closed fahseltc closed 1 year ago

fahseltc commented 1 year ago

Im writing an application that gets installed to c:\programfiles(x86) and when installed by the MSI, it sets up a scheduled task to run the app on login with the following CMD call. [SystemFolder]SCHTASKS.EXE /create /sc ONLOGON /tn APPNAME /tr [APPLICATIONROOTDIRECTORY]APPNAME.exe -l autorun /rl HIGHEST /f /ru interactive

This creates a task that when viewed in TaskScheduler UI has the "security option" -> "When running the task, use the following user account: INTERACTIVE"

I am trying to replicate that behavior in C# when the application is running to enable/disable that scheduled task. So far, all I can find is how to set things to run as system, but in that case the applications UI doesn't appear. Can you help me replicate this cmd line functionality in c# code? I believe its the "/ru interactive" part of the command that I'm having trouble replicating.

Thanks

dahall commented 1 year ago

See #336

dahall commented 1 year ago

@fahseltc Resolved?