Xp IP Security Policy ipseccmd and xp IP policy ipseccmd
/// Download ipsecure.exe // disable xp connection to public static void BannedXPRunCmd () {string str = Console. readLine (); Process p = new Process (); p. startInfo. fileName = "cmd.exe"; p. startInfo. useShellExecute = false; // whether to use the Operating System shell to start p. startInfo. redirectStandardInput = true; // accept the input information from the caller p. startInfo. redirectStandardOutput = true; // get the output information by the calling program p. startInfo. redirectStandardError = true; // redirected standard error output p. startInfo. create NoWindow = true; // do not display the program window p. start (); // Start the program // jump to the specified path and enter the str = "cd" + Application. startupPath + @ "\ lib"; p. standardInput. writeLine (str); // create an Ip policy (block all connections ), assign str = "ipseccmd-w REG-p BannedConnectIP-r BannedConnectIP-f 0 + *-n BLOCK-x"; p. standardInput. writeLine (str); // run the configuration IP to access string StrIPArr = ConfigurationSettings. appSettings ["RemoteIPAddr"]; if (StrIPArr. contains (',') {string [] st RArr = StrIPArr. split (','); for (int I = 0; I <strArr. length; I ++) {string strarr = strArr [I]. toString (); str = "ipseccmd-w REG-p BannedConnectIP-r AllowConnectIP (" + strarr + ")-f 0 +" + strarr + "-n PASS-x "; p. standardInput. writeLine (str) ;}} else {str = "ipseccmd-w REG-p BannedConnectIP-r AllowConnectIP (" + StrIPArr + ") -f 0 + "+ StrIPArr +"-n PASS-x "; p. standardInput. writeLine (Str);} // create an Ip policy (allow 155 connections) and assign // str = "ipseccmd-w REG-p BannedConnectIP-r AllowConnectIP (155) -f 0 + 192.168.1.155-n PASS-x "; // p. standardInput. writeLine (str); p. standardInput. writeLine ("exit"); p. standardInput. autoFlush = true; // write the command to be executed to the standard input. Here, the & is the symbol of the batch processing command, indicating that the previous command executes the following (exit) command no matter whether the execution is successful or not. If the exit command is not executed, the ReadToEnd () command is called later () the method will be suspended. // symbols of the same type include & | the former indicates that the subsequent commands must be executed successfully before the previous command is executed successfully, the latter indicates that the subsequent command p. waitForExit (); // wait for the program to run and exit process p. close () ;}// open the xp connection public static void AllowXPRunCmd () {string str = Console. readLine (); Process p = new Process (); p. startInfo. fileName = "cmd.exe"; p. startInfo. useShellExecute = false; // whether to use the Operating System shell to start p. startInfo. redirec TStandardInput = true; // accept the input information from the caller p. startInfo. redirectStandardOutput = true; // get the output information by the calling program p. startInfo. redirectStandardError = true; // redirected standard error output p. startInfo. createNoWindow = true; // do not display the program window p. start (); // Start the program // jump to the specified path and enter the str = "cd" + Application. startupPath + @ "\ lib"; p. standardInput. writeLine (str); // cancel str = "ipseccmd-w REG-p BannedConnectIP-y"; p. standardInput. writeLine (str); // deletion policy (Cancel the assignment before deletion) str = "ipseccmd-p BannedConnectIP-w reg-o"; p. standardInput. writeLine (str); p. standardInput. writeLine ("exit"); p. standardInput. autoFlush = true; // write the command to be executed to the standard input. Here, the & is the symbol of the batch processing command, indicating that the previous command executes the following (exit) command no matter whether the execution is successful or not. If the exit command is not executed, the ReadToEnd () command is called later () the method will be suspended. // symbols of the same type include & | the former indicates that the subsequent commands must be executed successfully before the previous command is executed successfully, the latter indicates that the subsequent command p. waitForExit (); // wait for the program to run and exit process p. close ();}