1

I was able to run a dll using rundll32.exe .

Now I want to run it as a windows service but it doesn't seem to start and gets timeout.

I am not sure how I could pass the parameters.

Trying something along the lines of ..

sc.exe create service binPath= "c:\windows\system32\rundll32.exe -test.dll -Main"

Trying the suggestions from creating a service with sc.exe; how to pass in context parameters but it doesnt seem to work.

Any suggestions?

Thanks,

Karthik

Community
  • 1
  • 1
user1621026
  • 55
  • 2
  • 11
  • What does not work? Did you check the Services Control Applet and review the commandline for `service`? – hmjd Aug 28 '12 at 16:03

1 Answers1

2

rundll32.exe can't act as service! You need helper like srvany.exe (from old Resource Kit).

Maximus
  • 10,751
  • 8
  • 47
  • 65
  • Hmm, I dont seem to have srvany.exe in Windows 7 and sc.exe cant run dll's as service.. – user1621026 Aug 28 '12 at 16:38
  • As I said, srvany is a part of old Windows resource kit. – Maximus Aug 28 '12 at 17:39
  • For the record, there's nothing in principle preventing a service from being implemented as a DLL and launched via rundll32. I believe you're right in thinking that this isn't what the OP is trying to do. – Harry Johnston Aug 28 '12 at 23:12
  • @Harry Johnston, sorry for disappointing you, but "service" is much more complacated, rather than simple profram. For example, service must call `StartServiceCtrlDispatcher` on startup. – Maximus Aug 29 '12 at 06:37
  • @Maximus: and you think a DLL can't call StartServiceCtrlDispatcher? I've written several services, I'm familiar with the technology. – Harry Johnston Aug 29 '12 at 07:43
  • I think, that rundll32 does not call StartServiceCtrlDispatcher. That was I mentioned. But the Dll itself - can. This is true. – Maximus Aug 29 '12 at 09:19