How to change start up type of a windows service using command line
My focus is on web server.
Apache web server does install serv开发者_StackOverflow中文版ice in automatic type (httpd -k install
) and Apache does not provide a parameter to install service in manual type (like MySQL: mysqld --install-manual
).
I read some about SC (C:\Windows\System32\sc.exe
) and tried to change it with SC but I couldn't. So what's the solution?
SC should be able to handle this, are you getting any errors?
This would set the startup type to manual for a service called 'apache' :
SC \\computername CONFIG apache start= demand
I just apply the same purpose --CHANGE WIN SERVICE STARTUP METHOD-- on a remote machine..
C:\MrCMD> REG QUERY \\RemoteHostName\HKLM\SYSTEM\CurrentControlSet\Services\WUAUServ
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ
Type REG_DWORD 0x20
Start REG_DWORD 0x2
ErrorControl REG_DWORD 0x1
ImagePath REG_EXPAND_SZ %systemroot%\system32\svchost.exe -k netsvcs
DisplayName REG_SZ Automatic Updates
ObjectName REG_SZ LocalSystem
Description REG_SZ Enables the download and installation of Windows updates. If this service is disabled, this computer will not be able to use the Automatic Updates feature or the Windows Update Web site.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ\Parameters
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ\Security
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ\Enum
┌─────────────────────────────────────┐
│ Executed Mon 01/14/2013 14:27:15.31 │ As [MrCMD]
└─────────────────────────────────────┘
C:\MrCMD> REG ADD \\RemoteHostName\HKLM\SYSTEM\CurrentControlSet\Services\wuauserv /V Start /T REG_DWORD /d 0x3
Value Start exists, overwrite(Yes/No)? y
The operation completed successfully.
┌─────────────────────────────────────┐
│ Executed Mon 01/14/2013 14:29:57.72 │ As [MrCMD]
└─────────────────────────────────────┘
C:\MrCMD> REG QUERY \\RemoteHostName\HKLM\SYSTEM\CurrentControlSet\Services\WUAUServ
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ
Type REG_DWORD 0x20
Start REG_DWORD 0x3
ErrorControl REG_DWORD 0x1
ImagePath REG_EXPAND_SZ %systemroot%\system32\svchost.exe -k netsvcs
DisplayName REG_SZ Automatic Updates
ObjectName REG_SZ LocalSystem
Description REG_SZ Enables the download and installation of Windows updates. If this service is disabled, this computer will not be able to use the Automatic Updates feature or the Windows Update Web site.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ\Parameters
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ\Security
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WUAUServ\Enum
┌─────────────────────────────────────┐
│ Executed Mon 01/14/2013 14:30:37.80 │ As [MrCMD]
└─────────────────────────────────────┘
That's all folks.. :)
精彩评论