Jump to content

Diskpart


Eagle710

Recommended Posts


If you can have diskpart output info, then yes. List Vol command will show drive letters, file system type and size. You can use this info. Alternatively, the Imagex HTA code in my sig has VBScript that lists drives as well, and identifies the type of drive it is. The only thing wrong is that it sees mapped network drives as hard drives, but does correctly identify USB Keys as USB-Drive.

Link to comment
Share on other sites

If you can have diskpart output info, then yes. List Vol command will show drive letters, file system type and size. You can use this info. Alternatively, the Imagex HTA code in my sig has VBScript that lists drives as well, and identifies the type of drive it is. The only thing wrong is that it sees mapped network drives as hard drives, but does correctly identify USB Keys as USB-Drive.

Which chunk of code would I need from your sig to get that?

Link to comment
Share on other sites

In the v7.1 version, there is a section called "Disk information" where it looks at the drives. You may or may not need the GimageX_COM.dll to be loaded. I am not so good at VBScript as others, I just keep that project going, not make any code changes. Its more of a community project now. Here is the code block, obviously you can't just use this peice as the vars are declared elsewhere in the HTA file, but it may give you a start at writing your own implementation.

Sub VolInfo(tmpstr1)
Dim strComputer, objWMIService, colDisks, objdisk, Size, strDriveType, FreeSpace, Totalfree, Space
StrComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
On Error Resume Next
For Each objDisk in colDisks

Select Case objDisk.DriveType
Case 1 strDriveType = "Unknown"
Case 2 strDriveType = "Usb-Drive"
Case 3 strDriveType = "Hard Disk"
Case 4 strDriveType = "Network disk"
Case 5 strDriveType = "CDROM"
Case 6 strDriveType = "RAM disk"
Case Else strDriveType = "Drive type Problem"
End Select

If strDriveType = "Hard Disk" OR strDriveType = "Usb-Drive" OR strDriveType = "Network disk" OR strDriveType = "RAM disk" Then
FreeSpace = Cint(objDisk.FreeSpace/1073741824)
Space = Cint(objDisk.Size/1073741824)
TotalFree = Space - FreeSpace
Size = "<TD align ='right'><B>Size: </B></TD>" & "<TD ALIGN = 'right' width='40px'>" & TotalFree & "GB / </TD><TD>" & Space & "GB</TD>"
Else
Size = " "
End If
tmpstr1 = tmpStr1 & "<TR><TD><B>" + objDisk.DeviceID & "\ " & objDisk.VolumeName & "</B><TD align='center'>" & "(" & strDriveType & ")" & "</TD><TD align='center'>" & "<B>" & objdisk.filesystem & "</B>" & Size & "</TD></TR>"
Next
On Error Goto 0



End Sub

Link to comment
Share on other sites

Is there a way by using diskpart or anyother means to automatically determine what volume/drive letter a USB key is assigned?

In case you don't want to fumble with Diskpart, there is another method, the old For Loop around the alphabet trick....

From there you can run scripts using the %MEDIA% variable like this.

%MEDIA%\Install\Office\Setup.exe

for %%i in (C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z:) do if exist %%i\sources\install.wim set MEDIA=%%i

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...