BlueSkyMemory Posted April 8, 2020 Share Posted April 8, 2020 Hello guys! I'm a rookie in AutoIt lol. I've tried to looking up in MSDN and the UDFs, but it can only get the GUID of a usual partition and with the GUID to control it. Now I have no ways😥. Thanks a lot for your help! Link to comment Share on other sites More sharing options...
Nine Posted April 8, 2020 Share Posted April 8, 2020 Have you tried Win32_DiskPartition class ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 8, 2020 Moderators Share Posted April 8, 2020 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
RTFC Posted April 9, 2020 Share Posted April 9, 2020 Maybe try this? My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 9, 2020 Author Share Posted April 9, 2020 23 hours ago, Nine said: Have you tried Win32_DiskPartition class ? Thanks a lot! But in WinPE, it is not able to use Powershell and WMI. Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 9, 2020 Author Share Posted April 9, 2020 6 hours ago, RTFC said: Maybe try this? Thanks, it works fine! But it's a pity that it doesn't support GPT disk. Link to comment Share on other sites More sharing options...
Nine Posted April 9, 2020 Share Posted April 9, 2020 What about diskpart ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Deye Posted April 9, 2020 Share Posted April 9, 2020 (edited) You will need to add\build in the ms scripting package "WinPE-Scripting.cab" to your winpe to make it work "WinPE-PowerShell_en-us.cab" and more, Here are all or more packages that you can add in starting from a clean boot.wim @line 1 using the ADK Dism /Mount-Image /ImageFile:"C:\WinPE_amd64_PS\media\sources\boot.wim" /Index:1 /MountDir:"C:\WinPE_amd64_PS\mount" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab" Dism /Unmount-Image /MountDir:C:\WinPE_amd64_PS\mount /Commit Many years ago i have started using this for doin' the disk queries for my winpe boot project #include <Array.au3> _GetDriveInfos() Func _GetDriveInfos() $var = DriveGetDrive("FIXED") Local $aDiskDrive = 0 Dim $specifs[$var[0]][8] For $i = 1 To $var[0] Dim $Services = ObjGet('winmgmts:\\.\root\cimv2') Dim $DiskDrives = $Services.ExecQuery("Select Caption, DeviceID From Win32_DiskDrive") For $DiskDrive In $DiskDrives Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & $DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition") For $DiskPartition In $DiskPartitions Dim $LogicalDisks = $Services.ExecQuery("Associators of {Win32_DiskPartition.DeviceID='" & $DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition") For $LogicalDisk In $LogicalDisks If $LogicalDisk.DeviceID = $var[$i] Then $specifs[$i - 1][0] = StringUpper($var[$i]) $specifs[$i - 1][1] = $DiskDrive.Caption $specifs[$i - 1][2] = Round(DriveSpaceTotal($var[$i]) / 1000) $specifs[$i - 1][3] = Round(DriveSpaceFree($var[$i]) / 1000) $specifs[$i - 1][4] = StringFormat('%.2f', $LogicalDisk.Size / (1024 ^ 3)) & ' GB' $specifs[$i - 1][5] = $DiskPartition.DeviceID $specifs[$i - 1][6] = $LogicalDisk.VolumeName $specifs[$i - 1][7] = $DiskPartition.Type EndIf Next Next Next Next _ArrayDisplay($specifs, '$specifs') EndFunc ;==>_GetDriveInfos Good luck! Deye Edited April 9, 2020 by Deye Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 10, 2020 Author Share Posted April 10, 2020 12 hours ago, Nine said: What about diskpart ? Yes, I can use Diskpart and StringRegExp to make it work. But for compatibility and smaller size, I want to use API instead of other modules. Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 10, 2020 Author Share Posted April 10, 2020 (edited) 11 hours ago, Deye said: You will need to add\build in the ms scripting package "WinPE-Scripting.cab" to your winpe to make it work "WinPE-PowerShell_en-us.cab" and more, Here are all or more packages that you can add in starting from a clean boot.wim @line 1 using the ADK Dism /Mount-Image /ImageFile:"C:\WinPE_amd64_PS\media\sources\boot.wim" /Index:1 /MountDir:"C:\WinPE_amd64_PS\mount" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab" Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab" Dism /Unmount-Image /MountDir:C:\WinPE_amd64_PS\mount /Commit Many years ago i have started using this for doin' the disk queries for my winpe boot project #include <Array.au3> _GetDriveInfos() Func _GetDriveInfos() $var = DriveGetDrive("FIXED") Local $aDiskDrive = 0 Dim $specifs[$var[0]][8] For $i = 1 To $var[0] Dim $Services = ObjGet('winmgmts:\\.\root\cimv2') Dim $DiskDrives = $Services.ExecQuery("Select Caption, DeviceID From Win32_DiskDrive") For $DiskDrive In $DiskDrives Dim $DiskPartitions = $Services.ExecQuery("Associators of {Win32_DiskDrive.DeviceID='" & $DiskDrive.DeviceID & "'} Where AssocClass = Win32_DiskDriveToDiskPartition") For $DiskPartition In $DiskPartitions Dim $LogicalDisks = $Services.ExecQuery("Associators of {Win32_DiskPartition.DeviceID='" & $DiskPartition.DeviceID & "'} Where AssocClass = Win32_LogicalDiskToPartition") For $LogicalDisk In $LogicalDisks If $LogicalDisk.DeviceID = $var[$i] Then $specifs[$i - 1][0] = StringUpper($var[$i]) $specifs[$i - 1][1] = $DiskDrive.Caption $specifs[$i - 1][2] = Round(DriveSpaceTotal($var[$i]) / 1000) $specifs[$i - 1][3] = Round(DriveSpaceFree($var[$i]) / 1000) $specifs[$i - 1][4] = StringFormat('%.2f', $LogicalDisk.Size / (1024 ^ 3)) & ' GB' $specifs[$i - 1][5] = $DiskPartition.DeviceID $specifs[$i - 1][6] = $LogicalDisk.VolumeName $specifs[$i - 1][7] = $DiskPartition.Type EndIf Next Next Next Next _ArrayDisplay($specifs, '$specifs') EndFunc ;==>_GetDriveInfos Good luck! Deye Thank you! I've saved it in my disk lol. But it still depends on so many modules. And it cannot detect hidden partitions. Edited April 10, 2020 by BlueSkyMemory Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 12, 2020 Author Share Posted April 12, 2020 (edited) On 4/9/2020 at 2:51 PM, RTFC said: Maybe try this? I've found your code is so powerful! By the way, could you please help extract the part that determines whether it is an active partition? Thanks a lot! (To ensure which partitions can be booted) Edited April 12, 2020 by BlueSkyMemory Link to comment Share on other sites More sharing options...
RTFC Posted April 12, 2020 Share Posted April 12, 2020 Thanks. To make a partition bootable (NB: only one (1) partition can be bootable per physical drive, so you always need to edit two flags, not one), look for, and edit boolean IsPrimary (any non-zero value = True; usually 0x01 or 0x80); it's the first byte of each partition table entry in the MBR. In the UDF, see var $partition_active in Func _ReadPartitionEntry for more info. WARNING: any changes you make to these low-level descriptors is entirely your own responsibility. Please ensure you back up your entire physical drive (not just the files on it), before you start tampering with it. In this particular case, editing a single byte can result in your system no longer booting at all, and no easy way of fixing it. Only proceed if that scenario does not concern you at all. Musashi 1 My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 12, 2020 Author Share Posted April 12, 2020 3 hours ago, RTFC said: Thanks. To make a partition bootable (NB: only one (1) partition can be bootable per physical drive, so you always need to edit two flags, not one), look for, and edit boolean IsPrimary (any non-zero value = True; usually 0x01 or 0x80); it's the first byte of each partition table entry in the MBR. In the UDF, see var $partition_active in Func _ReadPartitionEntry for more info. WARNING: any changes you make to these low-level descriptors is entirely your own responsibility. Please ensure you back up your entire physical drive (not just the files on it), before you start tampering with it. In this particular case, editing a single byte can result in your system no longer booting at all, and no easy way of fixing it. Only proceed if that scenario does not concern you at all. I've got it! And do you know how to show a hidden partition? I mean, to give a letter to it. Link to comment Share on other sites More sharing options...
RTFC Posted April 13, 2020 Share Posted April 13, 2020 (edited) Assigning drive letters has got nothing to do with physical drives; you need to look into SetVolumeMountpoint for that. To hide/show logical volumes, see the remarks section of the UDF: - hide/unhide logical volumes (simply set/reset bit4 of a volume's Partition_Type in its (E)MBR partition entry) Edited April 13, 2020 by RTFC My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 13, 2020 Author Share Posted April 13, 2020 1 hour ago, RTFC said: Assigning drive letters has got nothing to do with physical drives; you need to look into SetVolumeMountpoint for that. To hide/show logical volumes, see the remarks section of the UDF: - hide/unhide logical volumes (simply set/reset bit4 of a volume's Partition_Type in its (E)MBR partition entry) OK, I've got these APIs. Now I can use FindFirstVolume and FindNextVolume to get all GUIDs, and then assign letter to them. But when I try to use Find First/Next VolumeMountPoint to find out its letter, I failed (actually it can only get the mountpoint I set to, not the drive letter.) Link to comment Share on other sites More sharing options...
Developers Jos Posted April 13, 2020 Developers Share Posted April 13, 2020 @BlueSkyMemory, The comment I made in your other thread was also meant for you! Do NOT quote each and every post you reply to, as that information is already there, so just reply with your answer unless there is a real need to quote something! Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 13, 2020 Author Share Posted April 13, 2020 Sorry that I don't know the rules clearly. I've got it! Link to comment Share on other sites More sharing options...
BlueSkyMemory Posted April 13, 2020 Author Share Posted April 13, 2020 OK. Now the problem is solved. Thanks to everyone! This is my code below, hoping to help others-- Func _GetVolumeMountPoint($sGUID) $tPathName = DllStructCreate("char[2048]") $aResult = DllCall("Kernel32.dll", 'bool', 'GetVolumePathNamesForVolumeNameA', 'str', $sGUID, 'str', $tPathName, 'dword', DllStructGetSize($tPathName), 'dword', DllStructGetPtr($tPathName)) ;~ _ArrayDisplay($aResult) Return $aResult[2] EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now