WMI 远程修改服务启动类型

                  ConnectionOptions options = new ConnectionOptions();
                options.Username = UserName;
                options.Password = PassWord;

                ManagementScope Conn = new ManagementScope(@"\\" + IP + @"\root\cimv2", options);
                Conn.Connect();

                ManagementPath path = new ManagementPath("Win32_Process");
                ManagementClass processClass = new ManagementClass(Conn, path, null);

                ManagementBaseObject inParams = processClass.GetMethodParameters("ChangeStartMode");

                //Parameters for creation of process.
                inParams["StartMode"] = "Auto";

                //Invoke Method.
                ManagementBaseObject outParams = processClass.InvokeMethod("ChangeStartMode", inParams, null);

posted on 2009-07-31 14:49  永无止境  阅读(354)  评论(0编辑  收藏  举报