Skip to content

Commit

Permalink
add switch in choco package to add to PATH as admin (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrihitz committed Sep 8, 2022
1 parent 047c495 commit d6d9209
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,13 @@ choco install tinytex
```

This will install TinyTeX and make the TeX Live package manager, `tlmgr`
available on PATH.
available on user PATH.

``` powershell
choco install tinytex -params "/AddToSystemPath"
```
This will install TinyTeX and make the TeX Live package manager, `tlmgr`
available on System PATH.

To uninstall TinyTeX, use the command:

Expand Down
14 changes: 11 additions & 3 deletions choco/tools/chocolateyinstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@ $packageArgs = @{
checksumType = 'md5'
}

Install-ChocolateyZipPackage @packageArgs
# get Package Parameters
$pp = Get-PackageParameters

Install-ChocolateyZipPackage @packageArgs

Write-Host "Running tlmgr path add"
# Adds to Path
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path add`""
if ($pp['AddToSystemPath'] -eq 'true') {
Write-Host "Running tlmgr AddToSystemPath"
# AddToSystemPath
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path --w32mode=admin add`""
}Else{
# AddToUserPath
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path add`""
}
Start-ChocolateyProcessAsAdmin $statementsToRun "cmd.exe"


Write-Host "Updating tlmgr"
#updates tlmgr
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat update --self`""
Expand Down
8 changes: 6 additions & 2 deletions choco/tools/chocolateyuninstall.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
$toolsDir = Get-ToolsLocation

$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path remove`""
Start-ChocolateyProcessAsAdmin $statementsToRun "cmd.exe"
If ([Environment]::GetEnvironmentVariables("User").Path -split ";" | ?{$_ -like "*TinyTeX\*"}){
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path remove`""
} Else{
$statementsToRun = "/C `"$toolsDir\TinyTeX\bin\win32\tlmgr.bat path --w32mode=admin remove`""
}

Start-ChocolateyProcessAsAdmin $statementsToRun "cmd.exe"

0 comments on commit d6d9209

Please sign in to comment.