Vlad Omelyanchuk
Vlad Omelyanchuk

Reputation: 3091

Can i start .Net Console Application under custom user?

I have a console application that i would like to run as 'MySpecificUser'. Can i specify this user in app.config?

Upvotes: 0

Views: 781

Answers (3)

Norbert Willhelm
Norbert Willhelm

Reputation: 2609

I don't think this is possible by editing the app.config.

You should rather use Process.Start in order to run the process under another user. You will need to provide a password for the user account otherwise it will not work.

Upvotes: 1

Oded
Oded

Reputation: 498904

You can use the runas utility in order to execute any program as a specific user.

This is not something you could specify in a config, however, not directly.

Upvotes: 2

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

No, you can't. By the time the config file is read by the CLR it is too late to specify the user the process runs under. On the other hand you could write a launcher console application in whose config file you specify a username and password which are used to run the actual application using for example this Process.Start overload.

Upvotes: 3

Related Questions