如何在visual c#中执行

时间:2014-06-27 11:17:34

标签: c#

我尝试使用visual c#中的以下代码进行无线ad-hoc。但它需要两次管理员批准。我该怎么解决?

感谢。

private void button5_Click(object sender, MouseEventArgs e)
    {           
        Process process = new Process();
        ProcessStartInfo startInfo = new ProcessStartInfo();
        startInfo.FileName = "netsh.exe";
        startInfo.Arguments = "wlan set hostednetwork mode=allow ssid=" + box1 + " key=" + box2;
        startInfo.Verb = "runas";
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        process.StartInfo = startInfo;
        process.Start();

        startInfo.FileName = "netsh.exe";
        startInfo.Arguments = "wlan start hostednetwork";
        startInfo.WindowStyle = ProcessWindowStyle.Hidden;
        process.StartInfo = startInfo;
        process.Start();
    }

0 个答案:

没有答案