Exemple #1
0
        public static Win32_Service[] GetWin32_Services(string machineName)
        {
            List <Win32_Service> lst = new List <Win32_Service>();

            System.Management.ManagementObjectCollection mg =
                WIN32.WmiAccess.GetInstancesOfClass(machineName, "Win32_Service");
            foreach (System.Management.ManagementObject m in mg)
            {
                WIN32.Win32_Service src = new DotNet.Tools.WIN32.Win32_Service(m);
                lst.Add(src);
            }
            return(lst.ToArray());
        }
        private void btnInstall_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtPathService.Text.StartsWith(@"\\"))
                {
                    throw new
                        Exception("No se permiten rutas UNC para la instalacion del servicio. Especifique la ruta local del servicio");
                }
                if (txtServicename.Text == null || txtServicename.Text == "")
                {
                    throw new Exception("Especifique un nombre para el servicio");
                }
                if (txtServer.Text == null || txtServer.Text == "")
                {
                    throw new Exception("Especifique el nombre del servidor");
                }

                string mode = cbStartmode.SelectedItem.ToString();

                WIN32.Win32API.ServiceStartMode st =
                    (WIN32.Win32API.ServiceStartMode)Enum.Parse(typeof(WIN32.Win32API.ServiceStartMode), mode);

                WIN32.Win32API.ServiceReturnCode rt = new DotNet.Tools.WIN32.Win32API.ServiceReturnCode();

                if (ckuser.Checked)
                {
                    WIN32.Win32_Service sv = new DotNet.Tools.WIN32.Win32_Service(txtServer.Text);
                    rt = sv.Install(txtServer.Text, txtServicename.Text,
                        txtServicename.Text, txtPathService.Text,
                        st, txtUser.Text, txtPass.Text, null);
                }
                else
                {
                    WIN32.Win32_Service sv = new DotNet.Tools.WIN32.Win32_Service(txtServer.Text);
                    rt = sv.Install(txtServer.Text, txtServicename.Text,
                        txtServicename.Text, txtPathService.Text,
                        st, null, null, null);
                }

                if (rt != null) { MessageBox.Show("Resultado: " + rt.ToString()); }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
 private void Test8()
 {
     WIN32.Win32_Service w_serv = new DotNet.Tools.WIN32.Win32_Service("svapl02-36", "DeployServer 2.0", null, null);
     Console.WriteLine(w_serv.AcceptPause.ToString());
     Console.WriteLine(w_serv.Name);
     Console.WriteLine(w_serv.Status);
     Console.WriteLine(w_serv.SystemName);
 }
Exemple #4
0
 private void Test7()
 {
     WIN32.WmiAccess w_acc = new DotNet.Tools.WIN32.WmiAccess();
     WIN32.Win32_Service w_serv = new DotNet.Tools.WIN32.Win32_Service(w_acc);
     w_serv.Install("SVAPL02-36", "DeployServer 2.0", "Deploy Server 2.0",
             @"D:\Services .NET\dotNET\DeployServerSVCHost\", DotNet.Tools.WIN32.Win32API.ServiceStartMode.Disabled,
             @"UI\DI_ROSSELLO2","KUKUXUMUXU007",null);
 }
Exemple #5
0
        public static Win32_Service[] GetWin32_Services(string machineName)
        {
            List<Win32_Service> lst = new List<Win32_Service>();
            System.Management.ManagementObjectCollection mg =
                WIN32.WmiAccess.GetInstancesOfClass(machineName, "Win32_Service");
            foreach (System.Management.ManagementObject m in mg)
            {

                WIN32.Win32_Service src = new DotNet.Tools.WIN32.Win32_Service(m);
                lst.Add(src);

            }
            return lst.ToArray();
        }