S
sosh2785
Guest
Hi,
I am looking for c# code to execute batch file in D drive of the same server.
When I double click on bat file, it works.
I have tried below code but its not working. By the way, this code is used in Visual web part under sharepoint project.
string MyBatchFile = @"D:\TelA\notifi.bat";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
System.Security.SecureString ssPwd = new System.Security.SecureString();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = MyBatchFile;
//proc.StartInfo.Arguments = "args...";
proc.StartInfo.Domain = "mydomain";
proc.StartInfo.UserName = "username";
string password = "mypassword";
for (int x = 0; x < password.Length; x++)
{
ssPwd.AppendChar(password[x]);
}
proc.StartInfo.Password = ssPwd;
proc.Start();
Regards, Shreyas R S
Continue reading...
I am looking for c# code to execute batch file in D drive of the same server.
When I double click on bat file, it works.
I have tried below code but its not working. By the way, this code is used in Visual web part under sharepoint project.
string MyBatchFile = @"D:\TelA\notifi.bat";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
System.Security.SecureString ssPwd = new System.Security.SecureString();
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.FileName = MyBatchFile;
//proc.StartInfo.Arguments = "args...";
proc.StartInfo.Domain = "mydomain";
proc.StartInfo.UserName = "username";
string password = "mypassword";
for (int x = 0; x < password.Length; x++)
{
ssPwd.AppendChar(password[x]);
}
proc.StartInfo.Password = ssPwd;
proc.Start();
Regards, Shreyas R S
Continue reading...