C#: Load roaming profile and execute program as user

In an application I need to execute other programs with another user's credentials. Currently I use System.Diagnostics.Process.Start to execute the program:

public static Process Start(
   string fileName,
   string arguments,
   string userName,
   SecureString password,
   string domain

However this function does not load the roaming profile from the net - which is required.

I could use "runas /profile ..." to load the profile and execute the command, but that would ask for a password. There must be an more elegant way...

But where?



My solution (based on leppie's hint):

        Process p = new Process();

        p.StartInfo.FileName = textFilename.Text;
        p.StartInfo.Arguments = textArgument.Text;
        p.StartInfo.UserName = textUsername.Text;
        p.StartInfo.Domain = textDomain.Text;
        p.StartInfo.Password = securePassword.SecureText;

        p.StartInfo.LoadUserProfile = true;
        p.StartInfo.UseShellExecute = false;

        try {
        } catch (Win32Exception ex) {
            MessageBox.Show("Error:\r\n" + ex.Message);

Need Your Help

Defining new Query in Laravel 4

php laravel laravel-4 eloquent

I'm currently writing a back-end for a filter using Laravel 4. The view has a table with four columns: id, area, subarea and city. There are four text inputs, respectively, which send user's input ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.