This project has moved and is read-only. For the latest updates, please go here.

Update User Credentials

Topics: Examples
Jun 10, 2016 at 2:48 PM
I am trying to use the following code to update the user password on a task
ts.RootFolder.RegisterTaskDefinition("Test", td, TaskCreation.CreateOrUpdate, "User", "NewPassword", TaskLogonType.Password)
But right now I have to add every action, trigger, description, etc.

Is there a way to update just the user credentials without having to reassign every property of the task?
Jun 14, 2016 at 3:56 PM
var td = ts.RootFolder.Tasks["Test"];
// then call the method as you have above
Jun 14, 2016 at 7:58 PM
Edited Jun 14, 2016 at 8:02 PM
Thank you!

So, my code looks like this
  Using ts As New TaskService()
   Dim td = ts.RootFolder.Tasks("TEST")
  ts.RootFolder.RegisterTaskDefinition("TEST", td, TaskCreation.CreateOrUpdate, "User", "NewPassword", TaskLogonType.Password)
The td variable in my RegisterTaskDefiniton function gets an errors that says:
Value type of 'Task' cannot be converted to 'TaskDefinition'
Jun 16, 2016 at 5:27 PM
Edited Jun 16, 2016 at 5:55 PM
I apologize. The corrected code would be:
Using ts As New TaskService()
   Dim task = ts.RootFolder.Tasks("TEST")
   If task IsNot Nothing
      ts.RootFolder.RegisterTaskDefinition("TEST", task.TaskDefinition, TaskCreation.CreateOrUpdate, "User", "NewPassword", TaskLogonType.Password)
   End If
End Using
Marked as answer by dahall on 6/16/2016 at 9:27 AM