Search code examples
batch-filewmic

Look for volume D if found and volume size is greater than 1tb run DISKPART /S filename


As far as I understand I can use:

WMIC /node:"%computername%" LOGICALDISK GET Name

to get the name and I can use:

WMIC /node:"%computername%" LOGICALDISK GET size

to get the size.

I am have difficulties to get this working using a batch scripting.


Solution

  • As comparing the 1TB size would get difficult with batch, let wmic do the job

    WMIC /node:"%computername%" LOGICALDISK where "Name='D:' AND Size>1099511627776" Get  Name|findstr "^D:" && (
        DISKPART /S filename
    ) || (
        Echo Partition is less than 1TB
    )
    

    Otherwise you don't tell about the difficulties you have.