Jump to content

Add Right click .wim Windows 7 or Windows 8/8.1


Recommended Posts

Van, Mount R/W = Enter Image Index # ids fine if they actually know what the images are we had this long while back and had to post image indexes of x86 and x64.

I know they should use wim.info but not everyone will :(

If the problem exists between the keyboard and chair, then fix is simple. We need to use a more advanced snip to run the get-wiminfo first and pipe it's result to pre-populate a drop down list. Could probably capture the image description as well as the index #.

Edited by MrJinje
Link to comment
Share on other sites


I've found that when I elevate on Windows 8, I lose access to my shared map drive in Virtual Box. I can confirm this by running "as administrator" explorer.exe from the command line that the mapped drive does not exist under my full admin token (but does when I use Secpol.msc to auto-elevate requests without prompt), anybody else notice that ?

It reminds me of this...

GL

Link to comment
Share on other sites

I know they should use wim.info but not everyone will :(

I like the heck out of that Input box method cause it cleans it up

Perhaps this is simple fix cause trying to do a .wim info and stuffing that to an inputbox might be a nightmare.

I tend to forget that some trying to do this does no reading. They want fast and quick without any effort. Those of us been doing this awhile know and read a little before asking ?

I do show a pic of .wim info in 1st post

I modified the Inputbox

Enter Image Index # from .Wim Info

You can click Cancel in those boxes and then close cmd window no problem

post-9484-0-23443800-1348127994_thumb.pn

Edited by maxXPsoft
Link to comment
Share on other sites

Made a re-write (closes properly on input box cancel, avoids second message box/switch pop up, and cmd /c kills the cmd window afterwords), overall it seems much cleaner. When an input box is canceled it returns a null value, now that I know, this snip checks for that and exits. Else it runs the command without having to go into the second pop-up window. If the CMD /C kills the command window before it's done mounting try CMD /K (that might have been why I used it in the first place for DISM)

This is what's going into my next SLMGR, chop it up and edit your DISM bits in.


@="elevate cmd /c start /b powershell -command \"clear-host;[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');$KEY = [Microsoft.VisualBasic.Interaction]::InputBox('Enter Product Key', 'Enter a Product Key', 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX');If ($KEY -eq '') {exit} Else{wscript.exe C:\\Windows\\System32\\slmgr.vbs -ipk $KEY}\""


Got bored, copy pasta'd your snip into this.


@="cmd /k start /b powershell -command \"clear-host;[void][System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');$INDEX = [Microsoft.VisualBasic.Interaction]::InputBox('Enter Image Index #', 'Which image to mount', '1');If ($INDEX -eq '') {exit} Else{Dism /mount-wim /wimfile:\"%1\" /index:$INDEX /mountdir:C:\\zMountDir}\""


Still working on a get-wiminfo integration, here is sneak peak. Not liking the word wrap, gonna spend a little more time on it.

newimagel.png

Edited by MrJinje
Link to comment
Share on other sites

Still working on a get-wiminfo integration, here is sneak peak. Not liking the word wrap, gonna spend a little more time on it.

Try setting the message box Title longer. I have done that in normal VB to stretch the box.

looking good. I have been unable to do the wim info with UAC ON so am anxious to see what you done there. I am experimenting with the powershell big time.

Link to comment
Share on other sites

Try setting the message box Title longer. I have done that in normal VB to stretch the box.

looking good. I have been unable to do the wim info with UAC ON so am anxious to see what you done there. I am experimenting with the powershell big time.

Thanks will try that. Found a possible option for leaving UAC on and requesting elevation inline. If you check the last two lines, you'll also see a way to add a cmd.exe style 'pause' to Powershell. Most of it is comments, when I get time I will re-write it..

http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/09/23/a-self-elevating-powershell-script.aspx

UPDATE, here is rewrite, removed comments, deleted fluff, replaced double quotes, added variables to reduce length, added semi-colons everywhere.

$WID=[System.Security.Principal.WindowsIdentity]::GetCurrent();$WIP=new-object System.Security.Principal.WindowsPrincipal($WID);$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator;if ($WIP.IsInRole($adminRole)){}else{$newProcess = new-object System.Diagnostics.ProcessStartInfo 'PowerShell';$newProcess.Arguments = $myInvocation.MyCommand.Definition;$newProcess.Verb = 'runas';[System.Diagnostics.Process]::Start($newProcess);Write-Host 'Prompting for Elevation';exit;}Write-Host 'ElevatedCodeRunsHere';Write-Host -NoNewLine 'Press any key to continue...';$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');

and here's a snip regarding execution policy (for those who scrolled all the way to the end)

http://www.nivot.org/nivot2/post/2012/02/10/Bypassing-Restricted-Execution-Policy-in-Code-or-in-Script.aspx

If you want to run ps1 scripts in your own application, simply host your own Runspace and use the base authorization manager which pays no heed to system execution policy, even if it’s controlled by group policy and immune to powershell –bypass and set-executiopolicy:

Bypassing in Script

Now this is a little more hackish because it involves manipulating powershell.exe internals at runtime. This is a useful one-liner (if you can memorise it) when you find yourself in one of those clients who has GPO controlled execution policy. It’s pushing it for a one-liner, I know, but hey:

function Disable-ExecutionPolicy {
($ctx = $executioncontext.gettype().getfield(
"_context","nonpublic,instance").getvalue(
$executioncontext)).gettype().getfield(
"_authorizationManager","nonpublic,instance").setvalue(
$ctx, (new-object System.Management.Automation.AuthorizationManager
"Microsoft.PowerShell"))
}

Edited by MrJinje
Link to comment
Share on other sites

Interesting but it looked ugly when I done a 'dism /Get-WimInfo /WimFile:\"%1\"

I don't have a problem with UAC on in Win 8 except the Dism exe does not pause. It does execute the commands but won't pause.

Dism window flashes and then it pauses

I have this so far

@="cmd /c start /b powershell -command Dism /Get-WimInfo /WimFile:\"%1\";Write-Host -NoNewLine 'Press any key to continue...';$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown');"

Right now I don't have much time till possibly this weekend if I'm off to look at this.

Edited by maxXPsoft
Link to comment
Share on other sites

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)

Edited by MrJinje
Link to comment
Share on other sites

It's hardcoded to A:\Install.wim for testing. But you should be able to drop your %1 in it's place.

Yes I easily added that and it works fine in Win 7

The way it adds is different

Windows 7 install.wim Windows 8 install.wim

post-9484-0-90085900-1348845189_thumb.pnpost-9484-0-26165400-1348845222_thumb.pn

In windows 8 it gets plain ugly and does not add any of the images with UAC ON or OFF

back to the drawing board.

post-9484-0-99919900-1348846186_thumb.pn

Edited by maxXPsoft
Link to comment
Share on other sites

  • 2 weeks later...

Good work max. Check this out, it's a "metro" style rewrite of the old regedit jump trick. Not as nice as yours, but it does the trick.

Got any ideas on how to push a shell ext onto the taskbar /clock area ? Looking for any work-around that is right click available during maximized browser viewing and avoids switching to an explorer window or the desktop to right click.

http://forums.mydigitallife.info/threads/38208-Open-Regedit-directly-to-a-key

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...