zdarma
(Getting the hang of it)
2004-03-17 11:44 AM
Disable a service

Can anyone tell me how to disable a service under W2K? I know how to stop, start, pause, re-start and basically anything else I want to do to a service, but disable it. I am currently using NETSVC.EXE to stop/start services through a shell in my script. But I do need to disable the service because otherwise it will restart when the machine is rebooted.

I have tried to use MONITOR.EXE to disable certain services, but it doesn't seem to work.

I've checked Technet (an utter waste of time) and searched the web for an answer. I'm now turning to my fellow Kixsters to see if they have an idea.

Thanks in advance,
Z.


Bertje
(Fresh Scripter)
2004-03-17 11:49 AM
Re: Disable a service

try
net start <service name>
net stop <service name>

I dont know if there is one for restart

Code:
 
Shell "%comspec% /c net start <service name>"
Shell "%comspec% /c net stop <service name>"



zdarma
(Getting the hang of it)
2004-03-17 11:57 AM
Re: Disable a service

Bertje,

That's basically what I do right now for starting / stopping a service and it works like a charm. I just need to disable the service so that it doesn't start at the reboot. I do the following :

Quote:

Shell '%comspec% /c netsvc "THE SERVICE NAME" \\$answer_nt /stop'




I loooked at using the "manual" arguement, but if the user launches an application that calls the service, it will start the service, and I can't have the service running during a migration.

Thx,
Z.


JochenAdministrator
(KiX Supporter)
2004-03-17 12:02 PM
Re: Disable a service

have you ever heard of xnet ?
Well, it comes with KiXtart distribution and it has the capability of starting/stopping/disabling/installing/removing services even remotely


zdarma
(Getting the hang of it)
2004-03-17 02:26 PM
Re: Disable a service

Oh happy, happy, joy, joy

Thanks, never heard of XNET, always saw the directory with my kix sources, but never gave it much thought. I should have though, it worked like a charm. Thanks for the info.

Z.


zdarma
(Getting the hang of it)
2004-03-17 02:38 PM
Re: Disable a service

To anyone else who may be interested in using "XNET MODIFY". I'd like to let you konw that, although it isn't mentioned in the help text file (xnet.txt) under the MODIFY section, the command to disable a service is the following (atleast its the one I used and it worked).

Code:
 Shell '%comspec% /c XNET MODIFY "\\MACHINE NAME\SERVICE NAME" /s:DISABLE' 



l8r,
Z.


Breaker
(Hey THIS is FUN)
2004-03-17 02:43 PM
Re: Disable a service

If you have WMI available on the target machines on which you want to disable the service, then WMIService() is available in the UDF library.

You could use (for example):

Code:
$x = WMIService("messenger","STARTMODE","Disabled","computer_name")  



to disable the Messenger service on the remote computer "computer_name".


Sealeopard
(KiX Master)
2004-03-17 04:12 PM
Re: Disable a service

And, oh wonder, there are even UDFs available for this:
fnWMIService - Use the Win32_Service class of WMI to control services
ServiceMode() - Checks/sets the startup mode of a service