首页 > 其他 > 详细

2013-1-17 打开/关闭默认共享的命令

时间:2016-10-15 21:53:29      阅读:202      评论:0      收藏:0      [点我收藏+]

net share d$=d:\ 可打开d$的默认共享,但权限只有只读

net share d$=d:\ /grant:administrator,full 将d$的所有权限赋予administrator用户。

net share d$ /delete 删除此共享.

 

//一般访问

net use \\192.168.125.222\h$\naip_pdf "sininavchina6269" /user:"administrator"

 

System.Diagnostics.Process pro = new System.Diagnostics.Process();

 pro.StartInfo.FileName = "cmd.exe";            

pro.StartInfo.UseShellExecute = false;            

pro.StartInfo.RedirectStandardInput = true;            

pro.StartInfo.RedirectStandardOutput = true;            

pro.StartInfo.CreateNoWindow = true;            

pro.Start();                        

string cmdline = string.Format(@"net use {0} ""{1}"" /user:""{2}""", path, pass, user).ToLower();            

pro.StandardInput.WriteLine(cmdline);            

pro.StandardInput.WriteLine("exit");                        

// 截取输出流            

if (tb_output != null)

            {

                StreamReader reader = pro.StandardOutput;

                string line = reader.ReadLine();   // 每次读一行

                while (!reader.EndOfStream)  // 不为空则读取

                {

                    if (line != "")

                        tb_output.AppendText(line + Environment.NewLine);  // Environment .NewLine 换行

                                        line = reader.ReadLine().Trim();

                    line = line.ToLower();

                    Application.DoEvents();

                }

            }

            pro.WaitForExit();

            pro.Close();

2013-1-17 打开/关闭默认共享的命令

原文:http://www.cnblogs.com/mol1995/p/5965129.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!