How to run bat file with required permissions in C#?

How to run bat file with required permissions in C#?



SET SRC=%1
SET DEST=%2

xcopy /Y/I %SRC%*.txt %DEST%temp
echo Done!

var psi = new ProcessStartInfo(fileToRun);
psi.Arguments = args;
psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.WindowStyle = ProcessWindowStyle.Hidden;
psi.UseShellExecute = false;
psi.CreateNoWindow = true;

Process cmdProc = Process.Start(psi);

StreamReader output = cmdProc.StandardOutput;
StreamReader errors = cmdProc.StandardError;
cmdProc.WaitForExit();

psi.UseShellExecute = true;

psi.RedirectStandardOutput = false;
psi.RedirectStandardError = false;

psi.UserName = username;
psi.Password = password;

psi.RedirectStandardInput = true;

Comments

Popular posts from this blog

How to change this to <%Html.ActionLink%> in my asp.net mvc application ?