C\#에서 명령 행 cmd 를 호출 하여 와 이 파이 핫 이 슈 를 여 는 인 스 턴 스 코드

1383 단어 cmdwifi핫 이 슈

요점 1:cmd 명령 줄 의 입력 명령 netsh wlan set hostednetwork mode=allow ssid=사용자 이름  key=암호 netsh wlan start hostednetwork netsh waln stop hostednetwork netsh interface ip set address name="로 컬 연결"source=dhcp
요점 2:C\#에서 cmd.exe 명령 행 호출

       private void create(string str)
        {
            //process
            System.Diagnostics.Process p = new System.Diagnostics.Process();
            // cmd.exe
            p.StartInfo.FileName = "cmd.exe";
            //
            p.StartInfo.UseShellExecute = false;
            //
            //
            p.StartInfo.RedirectStandardInput = true;
            //
            p.StartInfo.RedirectStandardOutput = true;
            //
            p.StartInfo.RedirectStandardError = true;
            //
            p.StartInfo.CreateNoWindow = true;
            //
            p.Start();
            // 1s。
            System.Threading.Thread.Sleep(1000);
            //
            p.StandardInput.WriteLine(str);
            // 。
            p.StandardInput.WriteLine("exit");
        }


상세 한 코드 는 다음 과 같다.

좋은 웹페이지 즐겨찾기