0

I am aware that under windows 7 the command-line commands...

  • tasklist gets me processes (including services) currently running by it's executable name
  • net start shows me all the display names of started services. (“pretty” display names, not the shorter, space-less service names)

What I would like to achieve on the command line is

  • from executable name (wmiserv.exe) to the service name behind
  • vice versa (o.k., this way round could also be done in the services.msc panel, looking up the services properties)

If there was a command that, say, lists it all ( executable(+incl. path maybe), service name, display name) and I can grep my to the lines I need, that would be perfect.

I lack understanding, if separate rules for svchost-Services apply.

Example: I am currently try to find the service behind C:\Windows\System32\wmiserv.exe, which locks some files. Googling for such only gets one a wild bunch of search spam and dodgy „Download FixingTool.exe“. All I can find in the exe's Properties Dialog (assuming that it is benigm in the first plane) doesn't sound like any service name I can come up with.

1 Answer 1

1

I didn't find a single commando, but was able to do make a batch file for you.

Save the following code in a file 'GetServide.cmd' and run it from the command line.

To search for wmiservice.exe, the syntax would be something like: GetServide.cmd wmiservice.exe

@echo off

REM Syntax: GetService.cmd [keyword]

REM --- Get Keyword ---
Set Keyword=%1

REM --- Get all services ---
for /f "tokens=2" %%a in ('sc query^|find /i "SERVICE_NAME"') do Call :DoSearch %%a
Goto :EOF


REM --- Search Function ---
:DoSearch
  REM --- Set service name, quit if empty ---
  Set FoundOutput=
  Set SrvName=
  Set srv=%1
  if "%srv%"=="" goto :eof

  REM --- Serach keyword in services ---
  for /f %%a in ('sc qc "%1"^|find /i "%keyword%"') do set FoundOutput=%%a

  REM --- If keyword found, display info ---
  if "%FoundOutput%"=="" goto :eof
  ECHO.
  ECHO Service: %srv%
  sc qc "%1"|find /i "BINARY_PATH_NAME"
  sc qc "%1"|find /i "DISPLAY_NAME"
2
  • Sweet. I would have thought, there might be a direct command ( a bit like dir /X /N listing short and full ), but well, this does work. Thank you!
    – Frank N
    Sep 10, 2015 at 7:28
  • I was also suprised that no such thing was build into sc.exe.
    – ZEDA-NL
    Sep 10, 2015 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .