0

I have a bat file in which I have called a simple console application in c#. Whenever I run the bat file it displays the console and run. Can any one tell me how to run bat file as windows service so that to avoid this

wazza
  • 770
  • 5
  • 17
  • 42
  • Have you tried adding runas /user:domain\user "YourConsoleFilePathAndFileName" to the batch file? – David B Mar 10 '15 at 11:19
  • 1
    Please prevent this from being an XY problem, where X is _"I want to do something"_ and Y is your perceived solution to problem X: _"So I need to run this batch file as a Windows Service"_. You don't want this. You can use SrvAny to create a Windows Service from any application, but you really don't want to. Explain us your original problem X. Probably you're looking for a Scheduled Task, for example. – CodeCaster Mar 10 '15 at 11:27
  • Hai CodeCaster. I want the bat file to run in background even though after signing out from the user account – wazza Mar 10 '15 at 11:33

1 Answers1

0

I think this is what you're looking for:

Running a C# console application as a Windows service

It's not straightforward due to the fact that console app doesn't automatically qualify as a service, you will have to do some coding.

By the sound of your post though it seems as if you initially wanted to build a service in the first place, in that case, start from scratch and make a Windows service.

Community
  • 1
  • 1
bokibeg
  • 2,081
  • 16
  • 23