i have created a process using the Process class. now i need to restrict what all this new process can access like the permission for accessing internet,l or a special directory.
how can it be done.
my code so far is like this.
Process p = new Process()
{
StartInfo = new ProcessStartInfo(executablePath) {
CreateNoWindow = true,
ErrorDialog = false,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true,
WindowStyle = ProcessWindowStyle.Hidden,
StandardErrorEncoding = Encoding.UTF8,
StandardOutputEncoding = Encoding.UTF8,
UseShellExecute = false,
}
};
p.Start();
var outputStreamReader = p.StandardOutput;
var inputStreamWriter = p.StandardInput;
var errorStreamReader = p.StandardError;
p.WaitForExit();
string output = outputStreamReader.ReadToEnd();
string s = "";
You can restrict a process by starting it with a restricted user account – you need pass in the
UserNameandPassword(which is aSecureString) to the process either in theProcessStartInfoor directly on theProcessbefore starting it.