lundi 2 septembre 2019

Writing an if condition to read from a command output and execute a command if the output contains a string

I am new to batch scripting. I want to write an if condition to check if there is a Volume with the letter "Z" in disk part-- if exists then extend the FS, if not then create a new partition and install FS on it

I am trying a very simple code but my if condition is not working

wmic LogicalDisk GET DeviceID | find /i "Z"
if not errorlevel 1 (
    diskpart
    select disk 1
    creat partition primary
    format fs=ntfs
    assign letter=Z
) 
else (
    diskpart 
    select volume 3
    extend size = size
)

Aucun commentaire:

Enregistrer un commentaire