I have a few Jenkins builds that have tests that require an existing session (Windows GUI) so they cannot run as a service.
Because these tests (using nunit) do not need to install things on the machine they could easily run in separate terminal server sessions.
How is it possible to enable this, so it would start the tests (a batch script that is supposed to return zero on success) as a different user in a different session?
You can define a program (one of the tests in your case) in the Programs tab of an RDP connection and activate:
[✔] Start the following program on connection
You can start an RDP connection programmatically via mstsc: