install-miktex.ps1 1.67 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
# 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"
11
#Download the zip
12
13
14
15
$wcR.DownloadFile($url, $output)
Write-Output "Download completed $url"

Write-Output "unzip"
Jean-Francois Rey's avatar
Jean-Francois Rey committed
16
Expand-Archive -LiteralPath $output -DestinationPath 'C:\Windows\Temp\' -Force
17
18

Write-Output "Download repository"
Jean-Francois Rey's avatar
Jean-Francois Rey committed
19
C:\Windows\Temp\miktexsetup.exe --verbose --local-package-repository=C:\Windows\Temp\miktex --package-set=complete download
20
21
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
22
23

Write-Output "Install "
Jean-Francois Rey's avatar
Jean-Francois Rey committed
24
C:\Windows\Temp\miktexsetup.exe --quiet --local-package-repository=C:\Windows\Temp\miktex --package-set=basic --shared=no --common-install='C:\miktex' install
25
26
27

Write-Output "MiKTeX installed into C:\miktex"

Jean-Francois Rey's avatar
Jean-Francois Rey committed
28
29
30
31
32
33
if ( Test-Path "HKLM:\Software\MiKTeX.org\MiKTeX" ) {
	Write-Output "MiKTeX installed"
}
else {
	throw "ERROR: Can't install MiKTeX"
}
34

Jean-Francois Rey's avatar
Jean-Francois Rey committed
35
#Remove-Item 'C:\windows\Temp\miktex' -Recurse
Jean-Francois Rey's avatar
Jean-Francois Rey committed
36
Remove-Item $output -Force
Jean-Francois Rey's avatar
Jean-Francois Rey committed
37
#Remove-Item 'C:\Windows\Temp\miktexsetup.exe' -Force
Jean-Francois Rey's avatar
Jean-Francois Rey committed
38
# Add miktex to PATH <- done at install
39
#$oldpath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path
Jean-Francois Rey's avatar
Jean-Francois Rey committed
40
#$newPath = "$oldpath;C:\miktek\miktex\bin\x64"
41
#Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $newPath