I am starting a process with different user credential. I want that this process start as hidden. I am using fallowing code.But it doesn't work. The process starts as visible.
private void f(){
try {
System.Security.SecureString ssPwd = new System.Security.SecureString();
Process process = new Process();
process.StartInfo.UseShellExecute = false;
process.StartInfo.FileName = "app.exe";
process.StartInfo.Arguments = "Params";
process.StartInfo.LoadUserProfile = true;
process.StartInfo.Domain = domain;
process.StartInfo.UserName = username;
for (int x = 0; x < password.Length; x++) {
ssPwd.AppendChar(password[x]);
}
process.StartInfo.Password = ssPwd;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.Start();
process.WaitForExit();
} catch (Exception ex) {
Console.WriteLine("Exception occurred. " + ex.Message);
}
}