My bad, forgot to post the get-wiminfo cleanup routine. So far I've got it working from a batch file. Basically I hard-coded a 15 member array, parse the first 15 images of get-wiminfo results (if that many exist) and deletes any blank rows. The remaining rows pre-populate the text portion of the VB inputbox. Short names (like Windows 7 Pro, Windows 7 Home) show 2 on a line, and longer names wrap as shown in my pic. Have not found a way to add vbcrlf, 'r'n or [environment]::Newline to force new rows.
The mechanics of it are sound, but still needs work on the formatting and had planned on re-writing it shorter using some looping logic (which would remove the 15 image limitation of this snippet), but have not found the time.
I troubleshoot single line powershell from .cmd files before going to the registry to make things easier on myself. If you wanted to port back to normal powershell, split rows into readable chunks on the semi-colons ;;;; and then you can run the innards of the -command like normal (and use an IDE for troubleshooting).
$de = Image Index #: The #6 item in the get-wiminfo results array + every 5th item afterwords (6,11,16,etc) is the image index #, save for the last item which is "The operation completed successfully." (removed from array via script)
$ce = Version Name: The #7 item in the get-wiminfo results array + every 5th item afterwords (7,12,17,etc).
$ee = the filtered and formatted "Index#:Name" results that passes to the inputbox. Maybe we should convert this array to an
$fe string and manipulate before passing to the input box.
Get-wiminfo-tester.cmd - added some invisible rows to the code box to make it easier to select/copy.
@ECHO OFF
start /wait /b powershell -command "$WIM_FILE = 'A:\install.wim';$de = dism /get-wiminfo /WimFile:$WIM_FILE;$de = $de[6,11,16,21,26,31,36,41,46,51,56,61,66,71,76];$de = @($de | Where-Object {$_ -ne 'The operation completed successfully.'});$de = $de | Foreach-Object {$_ -replace 'Index :', ''};$de = $de | Foreach-Object {$_ -replace ' ', ''};$de;$ce = dism /get-wiminfo /WimFile:$WIM_FILE;$ce = $ce[7,12,17,22,27,32,37,42,47,52,57,62,67,72,77];$ce = @($ce | Where-Object {$_ -ne 'The operation completed successfully.'});$ce = $ce | Foreach-Object {$_ -replace 'Name :', ''};$ce = $ce | Foreach-Object {$_ -replace ' ', ''};$ce = $ce | Foreach-Object {$_ -replace 'WindowsServer', 'Server'};$ce;$ee = ':' , ':',':',':',':',':',':',':',':',':',':',':',':',':',':';$ee[0] = $de[0] + ':' + $ce[0];$ee[1] = $de[1] + ':' + $ce[1];$ee[2] = $de[2] + ':' + $ce[2];$ee[3] = $de[3] + ':' + $ce[3]; $ee[4] = $de[4] + ':' + $ce[4]; $ee[5] = $de[5] + ':' + $ce[5]; $ee[6] = $de[6] + ':' + $ce[6];$ee[7] = $de[7] + ':' + $ce[7]; $ee[8] = $de[8] + ':' + $ce[8];$ee[9] = $de[9] + ':' + $ce[9]; $ee[10] = $de[10] + ':' + $ce[10];$ee[11] = $de[11] + ':' + $ce[11];$ee[12] = $de[12] + ':' + $ce[12];$ee[13] = $de[13] + ':' + $ce[13];$ee[14] = $de[14] + ':' + $ce[14];cls;$ee = @($ee | Where-Object {$_ -ne ':'});$ee;cls;[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');$INDEX = [Microsoft.VisualBasic.Interaction]::InputBox($ee, 'Which image to mount','1');If ($INDEX -eq '') {exit} Else{Dism /mount-wim /wimfile:$WIM_FILE /index:$INDEX /mountdir:C:\\zMountDir}"
It's hardcoded to A:\Install.wim for testing. But you should be able to drop your %1 in it's place. All the other locations refer to $WIM_FILE once in powershell. I couldn't get it to work from the registry yet, but I've only spent about 5 minutes on that so far (yep you guessed it, it was the 5 minutes before I decided to make this post)
This post has been edited by MrJinje: 27 September 2012 - 12:05 AM