make an output appear in the same line

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
aleb
Posts: 2
Joined: 23 Aug 2013 00:21

make an output appear in the same line

#1 Post by aleb » 23 Aug 2013 00:40

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

Endoro
Posts: 244
Joined: 27 Mar 2013 01:29
Location: Bozen

Re: make an output appear in the same line

#2 Post by Endoro » 23 Aug 2013 02:12

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 :)

npocmaka_
Posts: 513
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: make an output appear in the same line

#3 Post by npocmaka_ » 23 Aug 2013 03:18


aleb
Posts: 2
Joined: 23 Aug 2013 00:21

Re: make an output appear in the same line

#4 Post by aleb » 23 Aug 2013 05:40

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 :)

Post Reply