Xp IP Security Policy ipseccmd and xp IP policy ipseccmd

Source: Internet
Author: User

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 ();}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.