Skip to content

Commit

Permalink
(chocolateyGH-1067) Add elevated cmd example
Browse files Browse the repository at this point in the history
Added additional example for cmd
Be careful, within the Here-String you need to double all the double quotes.
Add `cmd` example with note about spaces
  • Loading branch information
dragon788 authored and Russell Mora committed Jan 23, 2017
1 parent 490ee15 commit 2a70656
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Expand Up @@ -94,6 +94,14 @@ Start-ChocolateyProcessAsAdmin -Statements "$silentArgs" -ExeToRun $file -ValidE
$psFile = Join-Path "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" 'someInstall.ps1'
Start-ChocolateyProcessAsAdmin "& `'$psFile`'"
.EXAMPLE
# This also works for cmd and is required if you have any spaces in the paths within your command
$appPath = "$env:ProgramFiles\myapp"
$cmdBatch = "/c `"$appPath\bin\installmyappservice.bat`""
Start-ChocolateyProcessAsAdmin $cmdBatch cmd
# or more explicitly
Start-ChocolateyProcessAsAdmin -Statements $cmdBatch -ExeToRun "cmd.exe"
.LINK
Install-ChocolateyPackage
Expand Down
Expand Up @@ -111,6 +111,12 @@ public class ChocolateyInstallTemplate
## - https://chocolatey.org/docs/helpers-start-chocolatey-process-as-admin
#Start-ChocolateyProcessAsAdmin 'STATEMENTS_TO_RUN' 'Optional_Application_If_Not_PowerShell' -validExitCodes $validExitCodes
## To avoid quoting issues, you can also assemble your -Statements in another variable and pass it in
#$appPath = ""$env:ProgramFiles\appname""
##Will resolve to C:\Program Files\appname
#$statementsToRun = ""/C `""$appPath\bin\installservice.bat`""""
#Start-ChocolateyProcessAsAdmin $statementsToRun cmd -validExitCodes $validExitCodes
## add specific folders to the path - any executables found in the chocolatey package
## folder will already be on the path. This is used in addition to that or for cases
## when a native installer doesn't add things to the path.
Expand Down Expand Up @@ -173,4 +179,4 @@ public class ChocolateyInstallTemplate
#{{ChecksumTypex64}} - The checksum type for the 64-bit url | /ct64
";
}
}
}

0 comments on commit 2a70656

Please sign in to comment.