Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

Commit

Permalink
elevate permissions for list functinality and check os version and on…
Browse files Browse the repository at this point in the history
…ly use /all param if on win 8 or server 2012
  • Loading branch information
mwrock committed Sep 10, 2012
1 parent 9f88317 commit 6322ef4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions nuget/tools/chocolateysetup.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ $nugetChocolateyUpdateAlias = Join-Path $chocolateyExePath 'cup.bat'
$nugetChocolateyListAlias = Join-Path $chocolateyExePath 'clist.bat'
$nugetChocolateyVersionAlias = Join-Path $chocolateyExePath 'cver.bat'
$nugetChocolateyWebPiAlias = Join-Path $chocolateyExePath 'cwebpi.bat'
$nugetChocolateyWinFeaturesAlias = Join-Path $chocolateyExePath 'cwinfeatures.bat'
$nugetChocolateyWindowsFeaturesAlias = Join-Path $chocolateyExePath 'cwindowsfeatures.bat'
$nugetChocolateyCygwinAlias = Join-Path $chocolateyExePath 'ccygwin.bat'
$nugetChocolateyPythonAlias = Join-Path $chocolateyExePath 'cpython.bat'
$nugetChocolateyGemAlias = Join-Path $chocolateyExePath 'cgem.bat'
Expand Down Expand Up @@ -79,7 +79,7 @@ Write-Host "Creating `'$nugetChocolateyWebPiAlias`' so you can call 'chocolatey
SET DIR=%~dp0%
""$nugetChocolateyPath\chocolatey.cmd"" webpi %*" | Out-File $nugetChocolateyWebPiAlias -encoding ASCII

Write-Host "Creating `'$nugetChocolateyWinFeaturesAlias`' so you can call 'chocolatey windowsfeatures' from a shortcut of 'cwinfeatures'."
Write-Host "Creating `'$nugetChocolateyWindowsFeaturesAlias`' so you can call 'chocolatey windowsfeatures' from a shortcut of 'cwinfeatures'."
"@echo off
SET DIR=%~dp0%
""$nugetChocolateyPath\chocolatey.cmd"" windowsfeatures %*" | Out-File $nugetChocolateyWindowsFeaturesAlias -encoding ASCII
Expand Down
11 changes: 9 additions & 2 deletions src/functions/Chocolatey-List.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ param(
$webpiArgs ="/c webpicmd /List /ListOption:All"
& cmd.exe $webpiArgs
} elseif ($source -like 'windowsfeatures') {
$windowsFeaturesArgs ="/c dism /online /get-features /format:table"
& cmd.exe $windowsFeaturesArgs
$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyWindowsFeaturesInstall.log';
Remove-LastInstallLog $chocoInstallLog
$windowsFeaturesArgs ="/c dism /online /get-features /format:table | Tee-Object -FilePath `'$chocoInstallLog`';"
Start-ChocolateyProcessAsAdmin "cmd.exe $windowsFeaturesArgs" -nosleep
Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
foreach ($line in $installOutput) {
Write-Host $line
}
} else {

$srcArgs = Get-SourceArguments $source
Expand Down
11 changes: 8 additions & 3 deletions src/functions/Chocolatey-WindowsFeatures.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function Chocolatey-WindowsFeatures {
param(
[string] $packageName
)
Write-Debug "Running 'Chocolatey-WindowsFeatures' for $packageName with installerArguments:`'$installerArguments`'";
Write-Debug "Running 'Chocolatey-WindowsFeatures' for $packageName";

@"
$h1
Expand All @@ -12,12 +12,17 @@ $h1

$chocoInstallLog = Join-Path $nugetChocolateyPath 'chocolateyWindowsFeaturesInstall.log';
Remove-LastInstallLog $chocoInstallLog
$osVersion = (Get-WmiObject -class Win32_OperatingSystem).Version

$packageArgs = "/c DISM /Online /NoRestart /Enable-Feature /all /FeatureName:$packageName"
$packageArgs = "/c DISM /Online /NoRestart /Enable-Feature"
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..."
$statements = "cmd.exe $packageArgs | Tee-Object -FilePath `'$chocoInstallLog`';"
Start-ChocolateyProcessAsAdmin "$statements" -minimized -nosleep
Start-ChocolateyProcessAsAdmin "$statements" -minimized -nosleep -validExitCodes @(0,1)

Create-InstallLogIfNotExists $chocoInstallLog
$installOutput = Get-Content $chocoInstallLog -Encoding Ascii
Expand Down

0 comments on commit 6322ef4

Please sign in to comment.