Page 1 of 1

make an output appear in the same line

Posted: 23 Aug 2013 00:40
by aleb
hi all,
I made a very easy script which returns the name of the services configured as auto but actually stopped.
script:
@echo off
wmic service where 'startmode="auto" and state="stopped"' get name

The problem is that the output I receive is like this:
Name
gupdate
sppsvc
VMAuthdService


And I would like it to appear this way(without the "Name" title):
gupdate sppsvc VMAuthdService

is it possible? thanks

Re: make an output appear in the same line

Posted: 23 Aug 2013 02:12
by Endoro
you might try this:

Code: Select all

@ECHO OFF &SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "usebackqdelims=" %%a IN (`wmic service where 'startmode^="auto" and state^="stopped"' get name`) DO (
   FOR /f %%b IN ("%%~a") DO (
      SET /a counter+=1
      IF !counter! gtr 1 SET "line=!line! %%b"
   )
)
SET "line=%line:~1%"
ECHO(%line%


Btw. I really don't like wmic :)

Re: make an output appear in the same line

Posted: 23 Aug 2013 03:18
by npocmaka_

Re: make an output appear in the same line

Posted: 23 Aug 2013 05:40
by aleb
you might try this:
Code:
@ECHO OFF &SETLOCAL ENABLEDELAYEDEXPANSION
FOR /f "usebackqdelims=" %%a IN (`wmic service where 'startmode^="auto" and state^="stopped"' get name`) DO (
FOR /f %%b IN ("%%~a") DO (
SET /a counter+=1
IF !counter! gtr 1 SET "line=!line! %%b"
)
)
SET "line=%line:~1%"
ECHO(%line%


Btw. I really don't like wmic :)


great, just the solution I was looking for
thanks man :)