durex Posted March 31, 2005 Posted March 31, 2005 Not sure if anyone has touched on this before, but I recently came across another method of changing the properties of Windows services as opposed to using registry entries, its an actual command, which can be easily referenced from a script.Its using a Windows command called 'sc'. In a nutshell, this command allows you to do pretty much anything to a Windows service, such as starting / stoping a service (similar to net start/stop), renaming the service description and more usefully, it allows you to change the startup properties of a service, such as changing it to 'Disabled', 'Manual' or 'Automatic'.The main thing you need to be aware of is that to that you need to use Services' 'Key Name' as opposed to the 'Display Name'.i.e. The 'Automatic Updates' service Key Name is 'wuauserv' and the 'System Restore Service' service Key Name is 'srservice'.So the 1st thing you need to do (if you dont know it already) is find out the keyname for the service you want to change... how do you find that out?Easy: sc GetKeyName "<Display Name>"i.e. sc GetKeyName 'Task Scheduler' ...will return the Key name of 'Schedule'Once youve gotten the Key Name, the command for changing the startup type for the service is as follows:sc config <Service Key Name> start= <auto|demand|disabled>i.e. sc config srservice start= disabled The start types should be pretty obvious as to which applies to which startup type (Automatic, Manual, Disabled).As far as starting and stopping services, its the similar syntax to 'net start/stop' only difference is you still need to use the Service Key Name...sc start srserviceThere are a bunch of other things you can do with this command such as using it to change the Display Name and Description of a service, retrieve the current status of a service and even alter service properties on remote systems (assuming you have the permissions of course). You can read up in detail on it over at MS's site. Being a bigger fan of batch files , I hope others find this as useful as I do!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now