Archive: How can I DISABLE a windows service?


How can I DISABLE a windows service?
Hi, I have a question.
How can I DISABLE a windows service?
what instructions should I use?


Use the services plugin from here:
http://nsis.sourceforge.net/archive/download.php

-Stu


Thanks for your reply but that doesn't help me very much. I need to DISABLE a service not to pause or stop it.
Any ideea how I can do that?


Tried...
services::SendServiceCommand 'disable' 'MyServiceName'
...?

If that doesn't work, use this (DOS command):
http://www.computerhope.com/disable.htm#03

You can call it like so:
ReadEnvStr $R0 COMSPEC
nsExec::Exec "'$R0' /C '<command>'"

-Stu


I've tried both examples. None of them worked. Here is the code:
Example 1:

Section "disable help"
services::SendServiceCommand 'disable' 'helpsvc'
SectionEnd
; here the compiler says invalid command

Example 2:

Section "disable help"
ReadEnvStr $R0 COMSPEC
nsExec::ExecToLog "'$R0' /C 'disable helpsvc'"
SectionEnd
; no errors but it does nothing

Am I doing something wrong?


I found the answer. Here is the code to disable Help and Support service for example:

nsExec::ExecToLog 'sc config helpsvc start= "disabled"'


Look at the bottom of the following page:

http://www.experts-exchange.com/Prog..._20806097.html

It shouldn't be hard to compile that as a plug-in. You can also compile it as a regular DLL and call it with the System plug-in.


I wasn't able to compile that as a dll file. It gave me some errors. I've created a different dll but I'm not sure is perfectly build though. I've also read the "Calling an external DLL using the System.dll plugin" article but I didn't quite understand how to call from inside .nsi the function from my dll file.
If someone has time to help I would appreciate that.
Thanks.


The DLL you've attached doesn't have any exported functions, so there's nothing to call.

Open up Contrib\ExDLL\exdll.dsw and add the code in exdll.c. Compile it in release mode and you should your plug-in ready for usage in the Plugins folder. To use it, use this in your script:

ExDLL::ExportedFunctionName parameters

Thanks. I will try this. But, do you think that the dll file is good for what I need? Do you think the function ReconfigureSampleService is correctly build?