ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Activate/deactive a windows service with a script

<< < (2/3) > >>

Stoic Joker:
^Very good point^  :Thmbsup:

AndyM:
I have two batch files to turn on and off 2 services:

--- ---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.

mwb1100:
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


--- ---sc config wuauserv start= disabled

But not:


--- ---sc config wuauserv start = disabled
sc config wuauserv start=disabled

IainB:
net stop [service name]
net start [service name]
net restart [service name]
-Stoic Joker (August 04, 2012, 08:19 AM)
--- End quote ---
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:


IainB:
I have two batch files to turn on and off 2 services:

--- ---ServicesStart.bat:
@echo off
sc config wuauserv start= auto
...
Both have worked fine (Windows XP SP3) for years.
-AndyM (August 05, 2012, 01:53 PM)
--- End quote ---
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.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version