The COMExeception you are seeing is coming from the fact that you must match the username and the TaskLogonType. If you are choosing SYSTEM or NETWORK SERVICE, you much choose TaskLogonType.ServiceAccount, if you are choosing an interactive user, the InteractiveToken.
↧