Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: Task creation issue and login issue

$
0
0
What is happening and I don't understand is when the user installs my app it doesn't use the user name but goes to "System" and with the settings "Run whether user is logged on or not."

When I delete the task using your code which works and I re create the task using the code below It then create the task using my Login name instead of System and is set to Run only when user is logged on.


The task is created at first run in my program.
I don't understand why this is happening.


Here is the code that I am using. is below
Using ts As New TaskService

            ' Create a new task definition and assign properties
            Dim td As TaskDefinition = ts.NewTask
            td.RegistrationInfo.Description = "Test Startup"
            'Create trigger that fires 1 minutes after the system starts.
            td.Principal.UserId = Environment.UserName
            td.Principal.LogonType = TaskLogonType.InteractiveToken
            td.Triggers.Add(New LogonTrigger())
            td.Actions.Add(New ExecAction("C:\test.exe")
            td.Principal.RunLevel = TaskRunLevel.Highest
            td.Settings.Compatibility = TaskCompatibility.V2_1
            ts.RootFolder.RegisterTaskDefinition("test app", td)

        End Using
thank you for your help and support
Brock

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>