Beispiel #1
0
        /// <summary>
        /// TransfertToRemoteServer method implementation
        /// </summary>
        private bool TransfertToRemoteServer(string name, string machinename, int kind)
        {
            NTServiceClient manager = new NTServiceClient();

            manager.Initialize(machinename);
            INTService client = manager.Open();

            try
            {
                string targetname = "localhost";
                switch (kind)
                {
                case 1:
                    return(client.Start(name, targetname));

                case 2:
                    return(client.Stop(name, targetname));

                case 3:
                    return(client.Continue(name, targetname));

                case 4:
                    return(client.Pause(name, targetname));

                case 5:
                    return(client.IsRunning(name, targetname));

                case 6:
                    return(client.Exists(name, targetname));

                default:
                    return(client.Start(name, targetname));
                }
            }
            catch (Exception ex)
            {
                manager.UnInitialize();
                throw ex;
            }
            finally
            {
                manager.Close(client);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Stop method iplementation
        /// </summary>
        public static bool Stop(string name, string machinename)
        {
            NTServiceClient manager = new NTServiceClient();

            manager.Initialize();
            try
            {
                INTService client = manager.Open();
                try
                {
                    return(client.Stop(name, machinename));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }