Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to run tests as the `Local System` user?

I'm writing an integration test that requires the method to be run in the Local System security context to achieve the desired behavior. I couldn't achieve this yet. What should I do?

I'm using C#, VS 2010, MsTest and the target project is a Windows Service app.

like image 988
Jader Dias Avatar asked Dec 31 '25 07:12

Jader Dias


2 Answers

I see two options.

You can write a Windows service.

This is not as much work as it sounds. You can have that listen for commands, using e.g. WCF. If you set the privilege of that service to Local System you can have that service run your unit tests.

You can use scheduled tasks.

If you want your tests to run periodically, you can use scheduled tasks to schedule the task with the Local System privileges.

like image 159
Pieter van Ginkel Avatar answered Jan 02 '26 08:01

Pieter van Ginkel


This post could help you: the author is talking about running cmd as local system, but shoud work with nunit.exe as well so...

like image 21
Felice Pollano Avatar answered Jan 02 '26 07:01

Felice Pollano