c# : Create windows scheduled task as a different user
问题 I'm creating Windows Scheduled Tasks dynamically from c# using the build-in TaskService and TaskDefinition libraries. But for some of them, we need to create then to run as a different user (Local Service or Network Service). As the tasks are created and removed dynamically we cannot edit all of them manually to change the user. We need to do it via code. Is is possible? I've tried the following settings: TaskDefinition.Principal.Id = "NETWORK SERVICE"; TaskDefinition.Principal.LogonType =