I'm
using C#.NET, VS2005. I'm launching an application(app1) with the admin
user during system start up. From that application I want to run an
another application(app2). App2 will always work only when it is run by
the currently logged in user.
I used the Process class and set the ProcessStartInfo to set all
the user details, but it requires that I have to hard code all the user
name, password, which I don't want to do because in the password can be
different for different user.
Please help me how can I accomplish the same.
Launching an application with the currently logged in user
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Kirtan PatelRank #292 · 8.6K reputationPosted Apr 19, 2009, 7:10 AM EDT
u need to use SecureString to provide password
and U can get Current Username from Environment.Username
private void button1_Click(object sender, EventArgs e)
{
string CurrentUser = Environment.UserName;
string Password = "Kirtan12345";
System.Security.SecureString pass = new SecureString();
foreach (char c in Password)
{
pass.AppendChar(c);
}
Process p = new Process();
p.StartInfo.FileName = "NotePad.exe";
p.StartInfo.UserName = CurrentUser;
p.StartInfo.UseShellExecute = false;
p.StartInfo.Password = pass;
p.Start();
}
Happy Coding :)