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.
Loading
Kirtan PatelPosted Apr 19, 2009, 11:10 AM
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 :)