المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : run script - credentials



C# Programming
07-13-2009, 12:00 PM
Hello,
I have written the following code to execute a script on a remote machine.
This works fine using the default login details.
How do I modify this code so that the user's credentials are used.

string strScriptPath = strTargetFullPath;

System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "cscript.exe";
process.StartInfo.Arguments = strScriptPath;
process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
try
{
process.Start();
}
catch (Exception ex)
{

}

Thanks