Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. diagnostics;
/// <Summary>
/// Command Summary
/// </Summary>
Namespace command
{
Public class command
{
// <Summary>
// Run the specified command line
/// </Summary>
// <Param name = "cmd"> command </param>
// <Param name = "Arg"> command line parameters </param>
// <Param name = "comfirm"> write the confirmation information of the command line. </param>
// <Returns> </returns>
Public static string execute (string cmd, string Arg, string comfirm)
{
PROCESS p = new process ();
P. startinfo. filename = cmd;
P. startinfo. Arguments = ARG;
P. startinfo. useshellexecute = false;
P. startinfo. redirectstandardinput = true;
P. startinfo. redirectstandardoutput = true;
P. startinfo. redirectstandarderror = true;
P. startinfo. createnowindow = true;
P. Start ();
If (comfirm! = NULL)
P. standardinput. writeline (comfirm );
String MSG = P. standardoutput. readtoend ();
P. waitforexit ();
P. Close ();
Return MSG;
}
}
}
Call method command. Command. Execute ("cacls", filename + "/T/g everyone: F", "Y ");
Note that the cacls file name cannot contain spaces.
Method: you only need to use "" to cause the path.
For example, string filename = '"' + pathstr + '"';