Of course you can do it.
Most simple thing is using the Microsoft application SC.EXE which simply a console-oriented front-end communicating with the Service Controller, so it's easy to use in the batch files.
See
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sc.mspx?mfr=true[
^].
This utility is available in the Resource Kit, see
http://en.wikipedia.org/wiki/Windows_Resource_Kit[
^] and the references to Microsoft download pages at the bottom of this article.
You can control
installed services using the Service Controller in general and this utility in particular.
Also, you can embed the capabilities of controlling the service the way you described using Service Controller API. Actually you can implement such functionality in the same application as your service application. An instant of the process can determine if it is running as a service or interactively. If this is an interactive run, the process can look at command line (or even get a command from a special interactive-only UI) and perform the required operation on the registered service. I'm not giving you any further detail just because you did not share your platform and language. I did it only on .NET. Also, it seems to be you rather look for a solution like the one based on SC.EXE.
—SA