참고 문서: https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/sc-config

 

윈도우에서 서비스 시작 유형(=startup type, start type)을 설정해봅시다.

 

서비스의 시작 유형은 아래와 같습니다

  • boot(부트) - Specifies a device driver that is loaded by the boot loader
    • 부트로더가 로드하는 장치 드라이버
  • system(시스템) - Specifies a device driver that is started during kernel initialization
    • 커널 초기화하는 동안 시작되는 장치 드라이버
  • auto(자동) - Specifies a service that automatically starts each time the computer is restarted and runs even if no one logs on to the computer
    • 컴퓨터를 재시작할 때 로그인 된 사용자가 없어도 자동으로 실행되는 서비스
  • demand(수동) - Specifies a service that must be started manually. This is the default value if start= is not specified
    • 수동으로 시작해야 하는 서비스. start=가 지정되지 않은 경우 서비스의 시작 유형 기본값
  • disabled(사용 안 함) - Specifies a service that cannot be started. To start a disabled service, chang the start type to some other value
    • 시작할 수 없는 서비스. 시작하려면 시작 유형을 다른 값으로 변경해야 함
  • delayed-auto(자동(지연된 시작)) - Specifies a services that starts automatically a short time after other auto services are started
    • 다른 auto 서비스가 시작된 다음 시간이 조금 지난 뒤 실행되는 서비스

 

변경 방법은 여러가지가 있으니 아래 방법 중 편한거 쓰면 됩니다 

 

 

1. 서비스

간단하게 서비스(services.msc)를 실행해 GUI로 수정할 수 있습니다.

 

시작 - 서비스(또는 services.msc)를 검색해 서비스를 실행합니다.

'작업 관리자 - 서비스 - 서비스 열기'로도 들어올 수 있습니다

그 다음 변경할 서비스를 찾아 우클릭 - 속성을 눌러줍니다.

 

속성창에서 해당 서비스의 시작 유형을 변경할 수 있습니다.

설정할 수 있는 시작 유형은 자동(지연된 시작), 자동, 수동, 사용 안 함 4가지입니다.

 

 

2. sc.exe

cmd 또는 PowerShell에서 sc(Service Control)를 사용해 서비스 시작 유형을 변경할 수 있습니다.

cmd는 sc, PowerShell에서는 sc.exe를 입력해야 합니다. PowerShell에서는 Set-Content라는게 sc alias를 차지하고 있기 때문에 .exe를 붙여줘야 합니다.

 

PowerShell을 키고 sc.exe config을 입력해보면 설명이 나옵니다

sc.exe로 설정할 수 있는 시작 유형은 boot, system, auto, demand, disabled, delayed-auto 전부 가능합니다.

 

PS C:\Windows\system32> sc.exe config mongodb start=demand
[SC] ChangeServiceConfig 성공

위와 같이 입력해 서비스 시작 유형을 변경할 수 있습니다.

위에 적은 명령어는 mongoDB의 시작 유형을 수동으로 바꾸는 예시입니다.

 

 

3. Set-Service

PowerShell에서 Set-Service를 사용해서 서비스 시작 유형을 변경할 수도 있습니다.

PS C:\Windows\system32> Set-Service MongoDB -StartupType Manual

mongoDB의 시작 유형을 수동으로 바꾸는 예시입니다.

Set-Service는 시작 유형을 Automatic, Manual, Disabled만 설정 가능합니다. 대소문자는 구분하지 않습니다.

 

Get-Service를 이용해 변경된 서비스 시작 유형을 확인할 수 있습니다.

PS C:\Windows\system32> Get-Service MongoDB | select -property name,starttype

Name    StartType
----    ---------
MongoDB    Manual

 

반응형