|
Contro
|
 |
« on: August 04, 2012, 08:09:11 AM » |
|
Activate/deactive a windows service with a script
I would like to be able with a script to activate a windows service for windows xp pro The same, but deactivate that service.
P.D. Really I would like to run or stop the service, but may be more general and allow in some cases to abilitate the service o eliminate.
Best Regards
|
|
|
|
|
Logged
|
|
|
|
|
Stoic Joker
|
 |
« Reply #1 on: August 04, 2012, 08:19:16 AM » |
|
net stop [service name] net start [service name] net restart [service name]
|
|
|
|
|
Logged
|
|
|
|
|
AbteriX
|
 |
« Reply #2 on: August 04, 2012, 09:03:18 AM » |
|
C:\>sc
DESCRIPTION: SC is a command line program used for communicating with the NT Service Controller and services. USAGE: sc <server> [command] [service name] <option1> <option2>...
|
|
|
|
|
Logged
|
Greetings, Stefan.
|
|
|
|
|
|
|
Shades
|
 |
« Reply #4 on: August 04, 2012, 05:40:08 PM » |
|
Watch out with 'sc'.
At least read the manual very carefully, as it is quite a powerful tool. And it can wreak havoc in your system if you select (unintentionally) the wrong option for any (critical) service running in Windows.
Just sayin'.
|
|
|
|
|
Logged
|
|
|
|
|
Stoic Joker
|
 |
« Reply #5 on: August 05, 2012, 09:22:28 AM » |
|
^Very good point^ 
|
|
|
|
|
Logged
|
|
|
|
|
AndyM
|
 |
« Reply #6 on: August 05, 2012, 01:53:39 PM » |
|
I have two batch files to turn on and off 2 services: [ copy or print] ServicesStart.bat: @echo off sc config wuauserv start= auto sc config BITS start= auto sc start wuauserv sc start BITS ServicesStop.bat @echo off sc config wuauserv start= disabled sc config BITS start= disabled sc stop wuauserv sc stop BITS Both have worked fine (Windows XP SP3) for years.
|
|
|
|
|
Logged
|
|
|
|
|
mwb1100
|
 |
« Reply #7 on: August 05, 2012, 11:24:36 PM » |
|
One nit to be aware of with sc is that the options that use an "=" sign are very particular about the whitespacing. The "=" sign is actually part of the option name, so there cannot be a space before the equal sign, and there *must* be a space after. So But not: [ copy or print] sc config wuauserv start = disabled sc config wuauserv start=disabled
|
|
|
|
|
Logged
|
|
|
|
|
IainB
|
 |
« Reply #8 on: August 06, 2012, 12:07:00 AM » |
|
net stop [service name] net start [service name] net restart [service name]
Thanks @Stoic Joker. I had not known of this command previously. That's interesting. In Win7-64, the "NET" command only has these options - i.e., no RESTART: 
|
|
|
|
« Last Edit: August 06, 2012, 12:15:43 AM by IainB; Reason: Minor correction. »
|
Logged
|
|
|
|
|
IainB
|
 |
« Reply #9 on: August 06, 2012, 12:32:13 AM » |
|
I have two batch files to turn on and off 2 services: [ copy or print] ServicesStart.bat: @echo off sc config wuauserv start= auto ... Both have worked fine (Windows XP SP3) for years. Thanks @AndyM. I had not known of this command previously. In Win7-64, the "SC" has these options (see image below). I see that config is "persistent" and QUERY and QUERYEX look like they could be useful for avoiding redundant toggles - e.g., START or STOP of an already started or stopped service. 
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #10 on: August 06, 2012, 12:51:44 AM » |
|
That's interesting. In Win7-64, the "NET" command only has these options - i.e., no RESTART: You should be able to string it all together in one command like this: net stop <servicename> && net start <servicename>
|
|
|
|
|
Logged
|
|
|
|
|
Stoic Joker
|
 |
« Reply #11 on: August 06, 2012, 06:34:26 AM » |
|
That's interesting. In Win7-64, the "NET" command only has these options - i.e., no RESTART:
That probably has much to do with my not being a morning person, and it not actually existing.
|
|
|
|
|
Logged
|
|
|
|
|
IainB
|
 |
« Reply #12 on: August 06, 2012, 08:04:34 AM » |
|
That's interesting. In Win7-64, the "NET" command only has these options - i.e., no RESTART:
That probably has much to do with my not being a morning person, and it not actually existing. Ahahaha! I see. I thought it was a feature in XP that must have been removed in Win7-64. I was developing "XP-envy"!
|
|
|
|
|
Logged
|
|
|
|
|