home bbs files messages ]

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,653 of 68,980   
   JJ to Tom Del Rosso   
   Re: Finding names of services   
   21 Oct 20 19:10:16   
   
   From: jj4public@gmail.com   
      
   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=   
     )   
   )   
      
   --- 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