user2526047
user2526047

Reputation: 129

Batch variable only saving part of diskpart output

The output of the below code only takes the first word of each line. I want to see if the disk DYN or not.

    @echo off
    diskpart /s test9.txt

    for /f %%i in ('diskpart /s test9.txt') do echo %%i 

Code Outputs: Disk

[Dashed Lines]

Disk

How do I get the whole line?

Upvotes: 0

Views: 517

Answers (2)

Endoro
Endoro

Reputation: 37589

"tokens=*" removes leading spaces,this is not the issue here but for general reasons use better:

for /f "delims=" %%i in ('diskpart /s test9.txt') do echo %%i 

Upvotes: 3

RGuggisberg
RGuggisberg

Reputation: 4750

for /f "tokens=*" %%i in ('diskpart /s test9.txt') do echo %%i 

Upvotes: 0

Related Questions