OK,
That's what I thought, but it's not working for me, so here's the code I'm trying, could you tell me what I'm doing wrong please?
That's what I thought, but it's not working for me, so here's the code I'm trying, could you tell me what I'm doing wrong please?
'ask for the task name
Dim Taskname As String = InputBox("What's the task name?")
Dim td As TaskDefinition = Nothing
Try
'see if the username is set to something.
Dim ts As New TaskService
Dim thetask As Task = ts.GetTask(Taskname)
Dim Authorname As String = "NotGood"
Try
td = thetask.Definition
Authorname = td.RegistrationInfo.Author.ToString
Catch ex As Exception
Authorname = "NotGood"
End Try
'if we get a name, then this task was created by the 'wrong' user - try creating the task again to change the author.
If Authorname <> "NotGood" Then
td.Principal.RunLevel = TaskRunLevel.Highest
td.Principal.LogonType = TaskLogonType.InteractiveToken
td.RegistrationInfo.Author = "tevalis"
thetask.RegisterChanges()
ts.RootFolder.RegisterTaskDefinition(Taskname, td)
End If
Catch ex As Exception
MsgBox("Error - " & ex.Message)
End Try