Esempio n. 1
0
        private static int RunListServicesAndReturnExitCode(ListOptions opts)
        {
            //Check Admin right
            if (!DaemonMasterUtils.IsElevated())
            {
                Console.WriteLine("You must start the program with admin rights.");
                return(1);
            }

            try
            {
                Console.WriteLine("Number:  service name / display name");

                List <DmServiceDefinition> services = RegistryManagement.GetInstalledServices();
                for (var i = 0; i < services.Count; i++)
                {
                    var sb = new StringBuilder();
                    sb.Append(i);
                    sb.Append(": ");
                    sb.Append(services[i].ServiceName.Contains("DaemonMaster_") ? services[i].ServiceName.Remove(0, 13) : services[i].ServiceName); //Remove internally used prefix TODO: remove that on a later release
                    sb.Append(" / ");
                    sb.Append(services[i].DisplayName);
                    Console.WriteLine(sb);
                }

                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(1);
            }
        }