取消磁盘共享

实现效果:

  

知识运用:

  Process类

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
            myProcess.StartInfo.FileName="cmd.exe";
            myProcess.StartInfo.UseShellExecute = false;
            myProcess.StartInfo.CreateNoWindow = true;
            myProcess.StartInfo.RedirectStandardInput = true;
            myProcess.Start();
            myProcess.StandardInput.WriteLine("net share "+textBox1.Text+"$ /d");
            MessageBox.Show("执行成功!");
        }

  

原文地址:https://www.cnblogs.com/feiyucha/p/10303943.html