Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

running service from command line

Status
Not open for further replies.

gib99

Programmer
Mar 23, 2012
51
CA
Hello,

I have a service programmed in VS that compiles as a dll. To run the service, I need to open VS and run it. Is there a way to run my dll from the command line (i.e. without having to open VS)?
 
Gib,
You need to build a console app to actually execute your code.

You've got questions and source code. We want both!
Here at tek tips, we provide a hand up, not a hand out.
 
Qik3Coder said:
Gib,
You need to build a console app to actually execute your code.
That's actually what I want to do in the end.

I've recently learnt how to use

System.Diagnostics.Process.Start(pathToExe)

This works on exe's of course, not dlls, but I'm thinking there must be a similar way to run dlls. I know VS does it (when I hit F5) so why can't it be done from a command line. If I can figure that out, maybe I can take that command and pass it into

System.Diagnostics.Process.Start(command)

It will probably require a bit of tweeking since it's not exactly an executable (not necessarily) but I'm sure there must be a way to do it along these lines.

ralphtrent said:
It sounds like what you want to do svchost.exe will do for you but I do not see an easy way to hook your dll onto svchost, but i did come across article that may help you.


Scroll to the bottom to see one developers take.

Thanks for the link. They seem to be talking about something that requires you to "install" the service (into Window's registry, I presume). I looked up installing services the other day and came across this utility:

regsvr32

From what I read, if you put your dll in Windows/System32 and cd to that directory, then type "regsvr32 yourservice.dll", it should install it.

But when I try it, it tells me

regsvr32 said:
The module "yourservice.dll" was loaded but the entry-point DllRegisterServer was not found. Make sure that "yourservice.dll" is a valid DLL or OCX file and then try again.

Now, I don't mind modifying the source code to give it the entry-point DllRegisterServer (is that like Main?) but I'd rather not modify anything since it's not really my code (it belongs to the company and is under version control), so I'd prefer to use some alternate way of accomplishing my goal (if there is one). If there is no alternative, just let me know and I'll persue making it insatllable by this means. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top