# Install miktex for latex support Write-Output "Installing MiKTeX" Write-Output "Downloading installer" ## download last relase name $url = "https://miktex.org/download/win/miktexsetup-x64.zip" $output = 'c:\Windows\Temp\miktex.zip' $wcR = New-Object System.Net.WebClient Write-Output "Downloading $url" #Download the zip $wcR.DownloadFile($url, $output) Write-Output "Download completed $url" Write-Output "unzip" Expand-Archive -LiteralPath $output -DestinationPath 'C:\Windows\Temp\' -Force Write-Output "Download repository" C:\Windows\Temp\miktexsetup.exe --verbose --local-package-repository=C:\Windows\Temp\miktex --package-set=complete download Write-Output "Download repository again in case of trouble" C:\Windows\Temp\miktexsetup.exe --verbose --local-package-repository=C:\Windows\Temp\miktex --package-set=complete download Write-Output "Install " C:\Windows\Temp\miktexsetup.exe --quiet --local-package-repository=C:\Windows\Temp\miktex --package-set=basic --shared=no --common-install='C:\miktex' install Write-Output "MiKTeX installed into C:\miktex" if ( Test-Path "HKLM:\Software\MiKTeX.org\MiKTeX" ) { Write-Output "MiKTeX installed" } else { throw "ERROR: Can't install MiKTeX" } #Remove-Item 'C:\windows\Temp\miktex' -Recurse Remove-Item $output -Force #Remove-Item 'C:\Windows\Temp\miktexsetup.exe' -Force # Add miktex to PATH <- done at install #$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path #$newPath = "$oldpath;C:\miktek\miktex\bin\x64" #Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath