
dem3tre
-
Posts
25 -
Joined
-
Last visited
-
Days Won
1
Reputation Activity
-
dem3tre got a reaction from AshishNamdev in Microsoft diskpart automation
If you can stomach using an internal API function you can issue any command you wish to the diskpart console and get the following benefits automatically:
If diskpart coredumps/exits you can retrieve its termination code. If the command you send isn't recognized by diskpart, you'll be notified. The output returned is constrained to the current command session only so you don't have to worry about previous command results when parsing the output. Here's the function you should check out:
;; ;; Function : __dpIssueCommand ;; Description : Issues a command to the diskpart interactive console and captures its result. ;; Parameters : $pid : [in] running diskpart process identifier ;; $cmd : [in] command to issue ;; $output : [out] command output ;; Returns : Success : 1 ;; Failure : 0 ;; @ERROR : 0 = Success ;; : 1 = Failure ;; @EXTENDED : 2 = $_DP_ErrorCode_InvalidProcessID ;; : 3 = $_DP_ErrorCode_UnexpectedTermination ;; : 4 = $_DP_ErrorCode_StdoutStreamError ;; : 5 = $_DP_ErrorCode_StdinStreamError ;; : 7 = $_DP_ErrorCode_UnrecognizedCommand ;; Remarks : If @extended = 3 use _DiskpartTerminationCode to retreive its exit code ;;Checkout any of the _Diskpart*** functions to see how its used.
I do intend to wrap most diskpart commands to trap errors and simplify getting the results, but it may take a while with my current work schedule. In the mean time, I'll do my best to answer any questions.
Thanks !!
-
dem3tre got a reaction from AshishNamdev in Microsoft diskpart automation
Updated the Diskpart Automation API to Version 0.21
Added missing _DiskpartDetailVolume and _DiskpartDetailPartition functions.
Updated the demo code to show how you could use the new functions.
-
dem3tre got a reaction from AshishNamdev in Microsoft diskpart automation
Will add the remaining basic disk commands: assign, active, create, clean, delete, and remove tonight. I don't deal much with dynamic disks and the more server centric commands but will add them on request - just let me know which one you need. I'll also add a function that allows you to send raw commands to the console.
-
dem3tre got a reaction from AshishNamdev in Microsoft diskpart automation
Microsoft Diskpart Automation API
* UPDATED: 9 January 2007 ** Version 0.21 *
Added _DiskpartDetailVolume, _DiskpartDetailPartition, and updated the demo to show their use
The structure of the API is fairly stable now and should change little going forward as new functions are added.
The following functions are currently available:
Process commands: _DiskpartStartConsole......Begin an interactive diskpart session _DiskpartCloseConsole......Terminate an interactive diskpart session _DiskpartTerminationCode...Returns the last recorded diskpart process termination code Focus commands: _DiskpartSelectDisk.........Sets focus to the given disk _DiskpartSelectVolume.......Sets focus to the given volume _DiskpartSelectPartition....Sets focus to the given partition _DiskpartCurrentDisk........Returns the current in-focus disk _DiskpartCurrentVolume......Returns the current in-focus volume _DiskpartCurrentPartition...Returns the current in-focus partition Information commands: _DiskpartListDisks................Lists all fixed disks recognized by diskpart _DiskpartListVolumes..............Lists all volumes (including cd/dvd-rom and removeable) _DiskpartListPartitions...........Lists all partitions for the in-focus disk or volume _DiskpartListPartitionsByDisk.....Sets focus to the given disk and lists its partitions _DiskpartListPartitionsByVolume...Sets focus to the given volume and lists its partitions _DiskpartDetailDisk...............Obtains detailed information for the in-focus disk _DiskpartDetailVolume.............Obtains detailed information for the in-focus volume _DiskpartDetailPartition..........Obtains detailed information for the in-focus partition Management commands: TODO Helpful functions: TODO _DiskpartFindDiskByDiskID.........Returns the index of the disk with matching Disk ID (ie., 1CCE2CD3) TODO _DiskpartFindDisksByName..........Returns an array of disks that match the given name (ie., Maxtor OneTouch IIIs USB Device) TODO _DiskpartFindDisksByType..........Returns an array of disks of the given type (ie., USB, IDE) Please see the attached dpdemo.au3 file for an example on how to use this. I've done my best to document the code and make things easy to understand. The dpdemo-output.txt is the console output from the sample as run on my test box.win32.au3
diskpart.au3
dpdemo.au3
dpdemo_output.txt
-
dem3tre got a reaction from meoit in Microsoft diskpart automation
Microsoft Diskpart Automation API
* UPDATED: 9 January 2007 ** Version 0.21 *
Added _DiskpartDetailVolume, _DiskpartDetailPartition, and updated the demo to show their use
The structure of the API is fairly stable now and should change little going forward as new functions are added.
The following functions are currently available:
Process commands: _DiskpartStartConsole......Begin an interactive diskpart session _DiskpartCloseConsole......Terminate an interactive diskpart session _DiskpartTerminationCode...Returns the last recorded diskpart process termination code Focus commands: _DiskpartSelectDisk.........Sets focus to the given disk _DiskpartSelectVolume.......Sets focus to the given volume _DiskpartSelectPartition....Sets focus to the given partition _DiskpartCurrentDisk........Returns the current in-focus disk _DiskpartCurrentVolume......Returns the current in-focus volume _DiskpartCurrentPartition...Returns the current in-focus partition Information commands: _DiskpartListDisks................Lists all fixed disks recognized by diskpart _DiskpartListVolumes..............Lists all volumes (including cd/dvd-rom and removeable) _DiskpartListPartitions...........Lists all partitions for the in-focus disk or volume _DiskpartListPartitionsByDisk.....Sets focus to the given disk and lists its partitions _DiskpartListPartitionsByVolume...Sets focus to the given volume and lists its partitions _DiskpartDetailDisk...............Obtains detailed information for the in-focus disk _DiskpartDetailVolume.............Obtains detailed information for the in-focus volume _DiskpartDetailPartition..........Obtains detailed information for the in-focus partition Management commands: TODO Helpful functions: TODO _DiskpartFindDiskByDiskID.........Returns the index of the disk with matching Disk ID (ie., 1CCE2CD3) TODO _DiskpartFindDisksByName..........Returns an array of disks that match the given name (ie., Maxtor OneTouch IIIs USB Device) TODO _DiskpartFindDisksByType..........Returns an array of disks of the given type (ie., USB, IDE) Please see the attached dpdemo.au3 file for an example on how to use this. I've done my best to document the code and make things easy to understand. The dpdemo-output.txt is the console output from the sample as run on my test box.win32.au3
diskpart.au3
dpdemo.au3
dpdemo_output.txt