Setting service to manual

  • Thread starter Thread starter Brian
  • Start date Start date
B

Brian

I have a need to both stop and set the service to manual
through a batch file. Is there a switch or something I can
use to do this? I would envision something like:

net stop xxx -m

Any help would be appreciated.
 
If you have the resource kit, sc.exe will do this for you.
###########################################################
sc config -?:
Modifies a service entry in the registry and Service Database.
SYNTAX:
sc <server> config [service name] <option1> <option2>...
CONFIG OPTIONS:
NOTE: The option name includes the equal sign.
type= <own|share|interact|kernel|filesys|rec|adapt>
start= <boot|system|auto|demand|disabled>
error= <normal|severe|critical|ignore>
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
DisplayName= <display name>
password= <password>
###########################################################


If you don't have that or don't want to use it, you could try a poor man's
version something like:


net stop NameOfService
echo Windows Registry Editor Version 5.00>C:\service.reg
echo.>>C:\service.reg
echo
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NameOfServiceInRegistr
y]>>C:\service.reg
echo "Start"=dword:00000003>>C:\service.reg
regedit /s C:\service.reg
del C:\service.reg

Ray at work
 
p.s. I'm not sure if this matters, but regedit 5 files are supposed to be
in unicode, so may it'd be better to specify it as a regedit 4 version. ??
I don't know if this matters.

Ray at work

Ray at said:
If you have the resource kit, sc.exe will do this for you.
###########################################################
sc config -?:
Modifies a service entry in the registry and Service Database.
SYNTAX:
sc <server> config [service name] <option1> <option2>...
CONFIG OPTIONS:
NOTE: The option name includes the equal sign.
type= <own|share|interact|kernel|filesys|rec|adapt>
start= <boot|system|auto|demand|disabled>
error= <normal|severe|critical|ignore>
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
DisplayName= <display name>
password= <password>
###########################################################


If you don't have that or don't want to use it, you could try a poor man's
version something like:


net stop NameOfService
echo Windows Registry Editor Version 5.00>C:\service.reg
echo.>>C:\service.reg
echo
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NameOfServiceInRegistr
y]>>C:\service.reg
echo "Start"=dword:00000003>>C:\service.reg
regedit /s C:\service.reg
del C:\service.reg

Ray at work




Brian said:
I have a need to both stop and set the service to manual
through a batch file. Is there a switch or something I can
use to do this? I would envision something like:

net stop xxx -m

Any help would be appreciated.
 
In said:
I have a need to both stop and set the service to manual
through a batch file. Is there a switch or something I can
use to do this? I would envision something like:

net stop xxx -m

Not with net.exe.

SC.EXE from the Resource Kit can do it.
SYNTAX:
sc config [service name] <option1> <option2>...
CONFIG OPTIONS:
NOTE: The option name includes the equal sign.
type= <own|share|interact|kernel|filesys|rec|adapt|error>
start= <boot|system|auto|demand|disabled|error>
error= <normal|severe|critical|error|ignore>
binPath= <BinaryPathName>
group= <LoadOrderGroup>
tag= <yes|no>
depend= <Dependencies(separated by / (forward slash))>
obj= <AccountName|ObjectName>
DisplayName= <display name>
password= <password>

Or you can merge a .REG file (as Admin) to change the Start value of
the service.
0x2 Service_auto_start Loaded by the SCM
0x3 Service_demand_start Loaded by the SCM on demand
0x4 Service_disabled Disabled

And I'm sure WMI scripting could, but I do not have that answer.

There is another 3rd-party "service control" command-line program out
there, but I cannot recall the name at the moment. Free I think.
Perhaps somone will mention it here.
 
Ray at said:
p.s. I'm not sure if this matters, but regedit 5 files are supposed to be
in unicode, so may it'd be better to specify it as a regedit 4 version. ??

Yes, that would be more correct.

I don't know if this matters.

For most cases I don't think so, at least not when you create it the way you do
in your example where no unicode characters is needed in the file.
 
Back
Top