# prabhakarpandey/Not-ablle-to-install-window-service-by-using-TopShelf

> I am creating a window service by using console application.Below is my code:                        namespace ConsoleApplication1 {     //public class topshelf     //{     //    readonly Timer _timer;     //    public topshelf()     //    {     //        _timer = new Timer(10) { AutoReset = true};     //        _timer.Elapsed += (sender, eventArgs) => Console.WriteLine("It is {0} an all is well", DateTime.Now);     //    }     //    public void Start() { _timer.Start(); }     //    public void Stop() { _timer.Stop(); }     //}       public class MyService : IService     {         public void Start()         {             Console.WriteLine("Running...");         }           public void Stop()         {             Console.WriteLine("Done!");         }     }     public class Program     {          public static void Main(string[] args)         {          HostFactory.Run(x =>                                 //1             {                 x.Service<MyService>(s =>                        //2                 {                     s.ConstructUsing(name => new MyService());     //3                     s.WhenStarted(tc => tc.Start());              //4                     s.WhenStopped(tc => tc.Stop());               //5                 });                                  x.RunAsLocalSystem();                           //6                 x.SetDescription("Sample Topshelf Host");        //7                 x.SetDisplayName("MyService");                       //8                 x.SetServiceName("MyService");                       //9             });                                }     } }                                                                            PM> MySrvice.exe install  gives error The term 'MyService.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling o f the name, or if a path was included, verify that the path is correct and try again. At line:1 char:14 + MyService.exe <<<<  install     + CategoryInfo          : ObjectNotFound: (MyService.exe:String) [], CommandNotFoundException     + FullyQualifiedErrorId : CommandNotFoundException 

- **Canonical URL**: https://githubrepo.cloud/repo/prabhakarpandey/Not-ablle-to-install-window-service-by-using-TopShelf
- **GitHub Repository**: https://github.com/prabhakarpandey/Not-ablle-to-install-window-service-by-using-TopShelf
- **Maintainer / Creator**: https://github.com/prabhakarpandey
- **Discovered On**: Sep 26, 2026

---
*Indexed by GitHubRepo (https://githubrepo.cloud). Real-time open-source discovery & telemetry.*
