New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue with DISM "missing" or with the 32-bit DISM being called on a 64-bit system #393

Merged
merged 2 commits into from Jun 17, 2014

Conversation

Projects
None yet
5 participants
@dcjulian29
Contributor

dcjulian29 commented Dec 19, 2013

Recently while creating a chocolatey package, I ran into an issue where trying to install a windows feature would fail on my 64-bit windows operating system with a message saying that I could not use the 32-bit version of DISM to manage features. The reason this was happening was because of the 32-bit redirection that occurs on a 64-bit operating system. I also found an issue (#378) that seems to be related because either the DISM was not in the path or more likely it was due to the lack of a new line between the closing curly brace and the "cmd" and resulted in "none" of the code being executed in the elevated shell.

After reading the "contributing" document, I implemented the fix in a branch and sent a new pull request.

dcjulian29 added some commits Dec 19, 2013

Fixed issue 378 where DISM is missing because of a missing newline in…
… the command passed to the elevated shell and by specifying the exact path to the DISM tool instead of relying of the path of the system.
@ferventcoder

This comment has been minimized.

Member

ferventcoder commented Dec 19, 2013

Awesome! Thank you for doing that. This looks pretty clean and easy to pull
in.

On Thursday, December 19, 2013, Julian Easterling wrote:

Recently while creating a chocolatey package, I ran into an issue where
trying to install a windows feature would fail on my 64-bit windows
operating system with a message saying that I could not use the 32-bit
version of DISM to manage features. The reason this was happening was
because of the 32-bit redirection that occurs on a 64-bit operating system.
I also found an issue (#378https://github.com/chocolatey/chocolatey/issues/378)
that seems to be related because either the DISM was not in the path or
more likely it was due to the lack of a new line between the closing curly
brace and the "cmd" and resulted in "none" of the code being executed in
the elevated shell.

After reading the "contributing" document, I implemented the fix in a

branch and sent a new pull request.

You can merge this Pull Request by running

git pull https://github.com/dcjulian29/chocolatey dismIssue32bitOn64bit

Or view, comment on, or merge it at:

#393
Commit Summary

  • Fixed Issue where the 32-bit DISM will be called on a 64-bit OS when
    running a 32-bit shell/process
  • Fixed issue 378 where DISM is missing because of a missing newline
    in the command passed to the elevated shell and by specifying the exact
    path to the DISM tool instead of relying of the path of the system.

File Changes

Patch Links:

Rob
"Be passionate in all you do"

http://devlicio.us/blogs/rob_reynolds
http://ferventcoder.com
http://twitter.com/ferventcoder

@OlduwanSteve

This comment has been minimized.

OlduwanSteve commented Mar 21, 2014

Hi, first just to say thanks for finding this: I was trying to get 'windowsfeatures' to work properly with puppet, and it turns out I was running into this exact issue.

Anyway, this is just a note that 'dism' is also called from Chocolatey.List if the source is 'windowsfeatures', so the same fix needs to be applied there.

if($osVersion -ge 6.2) {
$packageArgs += " /all"
}
$packageArgs += " /FeatureName:$packageName"
Write-Host "Opening minimized PowerShell window and calling `'cmd.exe $packageArgs`'. If progress is taking a long time, please check that window. It also may not be 100% silent..." -ForegroundColor $Warning -BackgroundColor Black
$statements = $checkStatement + "cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`';"
$statements = $checkStatement + "`ncmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`';"

This comment has been minimized.

@ferventcoder

ferventcoder Mar 25, 2014

Member

This confuses me a bit.

This comment has been minimized.

@dcjulian29

dcjulian29 Apr 7, 2014

Contributor

It adds a new line to the statements variable which when output makes the printout more readable in my opinion... It doesn't change anything functionally.

This comment has been minimized.

@ferventcoder

ferventcoder May 28, 2014

Member

Ah, no worries.

@ferventcoder

This comment has been minimized.

Member

ferventcoder commented May 28, 2014

This looks good for rebasing into stable 👍

@jberezanski

This comment has been minimized.

Member

jberezanski commented May 29, 2014

The "sysnative" special alias is not a feature of "32-bit shells" (or cmd.exe in particular), rather it is provided by the WOW64 layer and available to all 32-bit applications running on 64-bit Windows, PowerShell included.
There is no need to pay the cost of invoking an intermediate cmd.exe.

$checkStatement=@"
`$dismInfo=(DISM /Online /Get-FeatureInfo /FeatureName:$packageName)
`$dismInfo=(cmd /c `"$dism /Online /Get-FeatureInfo /FeatureName:$packageName`")

This comment has been minimized.

@ferventcoder

ferventcoder Jun 17, 2014

Member

@jberezanski this is where you are talking about right?

This comment has been minimized.

@jberezanski

jberezanski Jun 17, 2014

Member

Yes,
``$dismInfo=(& '$dism' /Online /Get-FeatureInfo /FeatureName:$packageName)`
should do the trick. Likewise in the diff below.

# On a 64-bit OS, the 32-bit version of DISM can be called if the powershell host is 32-bit and results in an error...
# To fix this, we need to use a not-well know feature of 32-bit shells running on 64-bit OS, the "sysnative" directory.

This comment has been minimized.

@ferventcoder

ferventcoder Jun 17, 2014

Member

It's somewhat well-known if you have been working with ruby on windows, which up until recently was only available in 32bit.

@ferventcoder ferventcoder assigned ferventcoder and unassigned mwrock Jun 17, 2014

ferventcoder added a commit that referenced this pull request Jun 17, 2014

(GH-393) select default dism prior to check
This cleans up the docs a bit and removes the need for an else branch by
selecting a default dism and only modifying it if necessary.

ferventcoder added a commit that referenced this pull request Jun 17, 2014

(GH-393) Use sysnative for dism in List
This provides changes to List command to include use of sysnative as well.

ferventcoder added a commit that referenced this pull request Jun 17, 2014

Merge branch 'dismIssue32bitOn64bit' into stable
* dismIssue32bitOn64bit:
  (GH-393) Use sysnative for dism in List
  (GH-393) select default dism prior to check
  (maint) formatting
  Fixed issue 378 where DISM is missing because of a missing newline in the command passed to the elevated shell and by specifying the exact path to the DISM tool instead of relying of the path of the system.
  Fixed Issue where the 32-bit DISM will be called on a 64-bit OS when running a 32-bit shell/process

@ferventcoder ferventcoder merged commit f849a61 into chocolatey:master Jun 17, 2014

ferventcoder added a commit that referenced this pull request Jun 17, 2014

Merge branch 'stable'
* stable:
  (GH-393) Use sysnative for dism in List
  (GH-393) select default dism prior to check
  (maint) formatting
  (doc) Changelog / nuspec updates for release
  Fixed issue 378 where DISM is missing because of a missing newline in the command passed to the elevated shell and by specifying the exact path to the DISM tool instead of relying of the path of the system.
  Fixed Issue where the 32-bit DISM will be called on a 64-bit OS when running a 32-bit shell/process
@ferventcoder

This comment has been minimized.

Member

ferventcoder commented Jun 17, 2014

Thanks, this has been merged into stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment