Skip to content

Selecting drive without vbs script hook #3

@astachowski

Description

@astachowski

As the old UI++ forum isn't working anymore I hope it's OK if I post a snipplet here for selecting hard drives (2 - may be extended) just by querying WMI.
And thank you for UI++ - it's an absolute lifesaver for user driven setups.


<Action Type="WMIRead" Variable="DriveIndex0" Namespace="root\cimv2" Property="Index" Query="Select * from Win32_DiskDrive Where Index=0"/>
<Action Type="WMIRead" Variable="DriveModel0" Namespace="root\cimv2" Property="Model" Query="Select * from Win32_DiskDrive Where Index=0"/>
<Action Type="WMIRead" Variable="DriveBytes0" Namespace="root\cimv2" Property="Size" Query="Select * from Win32_DiskDrive Where Index=0"/>
<Action Type="WMIRead" Variable="DriveIndex1" Namespace="root\cimv2" Property="Index" Query="Select * from Win32_DiskDrive Where Index=1"/>
<Action Type="WMIRead" Variable="DriveModel1" Namespace="root\cimv2" Property="Model" Query="Select * from Win32_DiskDrive Where Index=1"/>
<Action Type="WMIRead" Variable="DriveBytes1" Namespace="root\cimv2" Property="Size" Query="Select * from Win32_DiskDrive Where Index=1"/>

<Action Type="TSVar" Name="DriveSize0" Condition='%DriveBytes0% < 1000 ^ 4'>Round(%DriveBytes0% / 1000 ^ 3) & " GB"</Action>
<Action Type="TSVar" Name="DriveSize0" Condition='%DriveBytes0% >= 1000 ^ 4 AND %DriveBytes0% < 1000 ^ 5'>Round(%DriveBytes0% / 1000 ^ 4) & " TB"</Action>
<Action Type="TSVar" Name="DriveSize1" Condition='%DriveBytes1% < 1000 ^ 4'>Round(%DriveBytes1% / 1000 ^ 3) & " GB"</Action>
<Action Type="TSVar" Name="DriveSize1" Condition='%DriveBytes1% >= 1000 ^ 4 AND %DriveBytes1% < 1000 ^ 5'>Round(%DriveBytes1% / 1000 ^ 4) & " TB"</Action>

<Action Type="Input" Name="OSDriveSelect" Title="Where should I install Windows?" ShowBack="True">
  <ChoiceInput Variable="ZZDriveNumber" Question="Select drive" DropDownSize="8" Required="False" Default="0" >
    <Choice Condition='"%DriveIndex0%" >= "0"' Option="Drive 1 - %DriveModel0% - %DriveSize0%" Value="0" />
    <Choice Condition='"%DriveIndex1%" >= "0"' Option="Drive 2 - %DriveModel1% - %DriveSize1%" Value="1" />
  </ChoiceInput>
</Action>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions