user2473819
user2473819

Reputation: 11

How to assign the output value of a command to a variable in Windows command prompt?

I want the output value of this command :

wmic logicaldisk where "DeviceID='C:'" get FreeSpace

to be assigned to a variable which I can use in an IF condition.

Upvotes: 1

Views: 2910

Answers (1)

foxidrive
foxidrive

Reputation: 41287

@echo off
for /f "skip=1" %%a in ('wmic logicaldisk where "DeviceID='C:'" get FreeSpace') do if not defined var set var=%%a
echo %var%

Upvotes: 2

Related Questions