Forums before death by AOL, social media and spammers... "We can't have nice things"
|    alt.msdos.batch.nt    |    Fun with Windows NT batch files    |    68,980 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 67,655 of 68,980    |
|    mokomoji to All    |
|    Re: Finding names of services    |
|    22 Oct 20 15:57:04    |
   
   From: mokomoji@naver.com   
      
   2020년 10월 21일 수요일 오후 9시 10분 19초 UTC+9에 JJ님이   
   작성한 내용:   
   > On Tue, 20 Oct 2020 10:13:39 -0400, Tom Del Rosso wrote:    
   > > If you run this:    
   > >    
   > > net stop LanmanServer /y    
   > >    
   > > The output is:    
   > >    
   > > The following services are dependent on the Server service.    
   > > Stopping the Server service will also stop these services.    
   > >    
   > > HomeGroup Listener    
   > > Computer Browser    
   > >    
   > > The HomeGroup Listener service is stopping.    
   > > The HomeGroup Listener service was stopped successfully.    
   > >    
   > > The Computer Browser service is stopping..    
   > > The Computer Browser service was stopped successfully.    
   > >    
   > > The Server service is stopping.    
   > > The Server service was stopped successfully.    
   > >    
   > > So then you want to restart the dependent services first,    
   > > and you can parse the output to get the names, but how can you translate    
   > > them into the short names?    
   > >    
   > > HomeGroup Listener=HomeGroupListener    
   > > Computer Browser=Browser    
   > >    
   > > It could be hard-coded but that's so...you know.    
   > >    
   > > Thank you.   
   > You can use the SC tool to list the services. e.g.    
   >    
   > sc query | find "_NAME"    
   >    
   > Or you can use below batch file to simplify the display for easy read    
   > format.    
   >    
   > @echo off    
   > setlocal enabledelayedexpansion    
   > set n=    
   > for /f "tokens=1,* delims= " %%A in ('sc query state^= all ^| find "_NAME"')    
   > do (    
   > if "%%A" == "SERVICE_NAME:" (    
   > if "!n!" == "" (    
   > set n=%%B    
   > ) else (    
   > echo !n!    
   > set n=    
   > )    
   > ) else if "%%A" == "DISPLAY_NAME:" (    
   > echo !n!: %%B    
   > set n=    
   > )    
   > )   
   cmd cheating   
   if nand...   
      
   [source]   
      
   @echo off   
   cd /d "%~dp0"   
   setlocal   
   set n=   
   for /f "usebackq tokens=1* delims= " %%f in (`sc query state^=all^|find   
   "_NAME:"`) do (   
   if /i "%%f" equ "SERVICE_NAME:" (call set "n=%%g") else (call set "n=%%n%% :   
   %%g")&&(call echo %%n%%&call set n=)   
   )   
   pause   
      
      
   [/source]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca