Como posso saber qual conta instalou um serviço do Windows?
Você pode usar wevtutil
para recuperar essas informações:
Retrieve information about event logs and publishers. Archive logs in a self-contained format, Enumerate the available logs, Install and uninstall event manifests, run queries, Exports events (from an event log, from a log file, or using a structured query) to a specified file, Clear event logs.
O evento que você precisa procurar é ID do Evento 4697: um serviço foi instalado no sistema :
A new service was installed by the user indicated in the subject. Subject often identifies the local system (SYSTEM) for services installed as part of native Windows components and therefore you can't determine who actually initiated the installation.
Subject:
The user and logon session that performed the action.
- Security ID: The SID of the account.
- Account Name: The account logon name.
- Account Domain: The domain or - in the case of local accounts - computer name.
- Logon ID is a semi-unique (unique between reboots) number that identifies the logon session. Logon ID allows you to correlate backwards to the logon event (4624) as well as with other events logged during the same logon session.
Service Information:
- Service Name: the internal system name of the new service.Use "sc query" to get a cross reference of service names and their more familiar display names.
O comando a seguir mostrará o Account Name
do último serviço criado:
wevtutil query-events System /count:1 /rd:true /format:text /q:"Event[System[(EventID=4697)]]"
Se você criou o serviço usando o comando sc create
, será necessário procurar a ID do Evento: 7045 Origem: service control manager e procurar User Name
:
wevtutil query-events System /count:1 /rd:true /format:text /q:"Event[System[(EventID=7045)]]"
Exemplo:
> sc create Notepad binpath= c:\windows\system32\Notepad.exe
[SC] CreateService SUCCESS
> wevtutil query-events System /count:1 /rd:true /format:text /q:"Event[System[(EventID=7045)]]"
Event[0]:
Log Name: System
Source: Service Control Manager
Date: 2017-04-07T14:35:32.600
Event ID: 7045
Task: N/A
Level: Information
Opcode: N/A
Keyword: Classic
User: S-1-5-21-1699878757-1063190524-3119395976-1000
User Name: Hal\DavidPostill
Computer: Hal
Description:
A service was installed in the system.
Service Name: Notepad
Service File Name: c:\windows\system32\Notepad.exe
Service Type: user mode service
Service Start Type: demand start
Service Account: LocalSystem
Leitura Adicional
- Um índice A-Z da linha de comando do Windows CMD - Uma excelente referência para todas as coisas relacionadas à linha do Windows cmd.
- sc - Controle de serviço - Crie, inicie, pare, consulte ou exclua qualquer serviço do Windows.
- wevtutil - Utilitário de linha de comando de eventos do Windows.