[tex-live] Running Live - no access to C drive
Siep Kroonenberg
siepo at cybercomm.nl
Thu Mar 15 13:15:31 CET 2007
On Thu, Mar 15, 2007 at 01:05:19PM +0100, Siep Kroonenberg wrote:
> WARNING: This e-mail has been altered by MIMEDefang. Following this
> paragraph are indications of the actual changes made. For more
> information about your site's MIMEDefang policy, contact
> Daimi virus/spamfilter <postmaster at daimi.au.dk>. For more information about MIMEDefang, see:
>
> http://www.roaringpenguin.com/mimedefang/enduser.php3
>
> An attachment named tl_start.vbs was removed from this document as it
> constituted a security hazard. If you require this document, please contact
> the sender and arrange an alternate means of receiving it.
Here is the script in-line:
' Prepare a Windows system for running TeX Live from dvd.
' This involves adding or changing some user environment variables
' and placing some files under %USERPROFILE%.
Option Explicit
On Error Resume Next
Dim bTlOnPath, sTLroot, sTLrootSl, sTLrootBin, sTLmain, sTLocal
Dim bGsOnPath, bGsFound, nGsVersion, sGsRoot, sGsRootParent
Dim bPerlOnPath
Dim i, j, k, l, m, n, sTemp, sTemp2, oFile
' load necessary functionality
Dim oWsh, oFS
Set oWsh = Wscript.CreateObject("WScript.Shell")
Set oFS = CreateObject("Scripting.FileSystemObject")
' functions and subroutines ''''''''''''''''''''
' Backslashes
Function Bsl( s )
Bsl = Replace( s, "/", "\" )
End Function
Function AddBsl(sDir)
Dim sTmp
sTmp = Bsl( sDir )
If Right( sTmp, 1 ) = "\" Then
AddBsl = sTmp
Else
AddBsl = sTmp & "\"
End If
End Function
Function RemoveSl(sDir)
If ( Right( sDir, 1 ) = "\" ) or ( Right( sDir, 1 ) = "/" ) Then
RemoveSl = Left( sDir, len( sDir ) - 1 )
Else
RemoveSl = sDir
End If
End Function
' convert Ghostscript versions from and to
' an integer between 800 and 999
Function num2version (i)
Dim numstr
numstr = CStr( i )
num2version = left( numstr, 1 ) & "." & right( numstr, 2 )
End Function
' search a program on the searchpath
Dim PathHelp
PathHelp = vbNewLine & _
"You can edit the search path as follows:" & vbNewLine & _
"right-click My Computer, choose Properties, Advance Tab," _
& vbNewLine & _
"Environment Variables button, and edit the Path entries" & _
" in either pane." & vbNewLine & _
"The top pane may not have a path entry but you may create one for it." _
& vbNewLine & _
"The bottom (system) path entry has priority over the top (user) one."
Function FindOnPath( s )
Dim paths, d, tmp
Err.clear()
paths = Split( oWsh.expandenvironmentstrings( "%path%" ), ";", -1 )
FindOnPath = ""
For Each d in paths
tmp = AddBsl( d )
If oFS.FileExists( tmp & s ) Then
FindOnPath = tmp
Exit For
End If
Next
End Function
' create a folder if it doesn't exist.
' bail out if the folder doesn't exist and can't be created.
sub CreateTry( sFolder )
If Not oFS.FolderExists( sFolder ) Then
oFS.CreateFolder( sFolder )
If Not oFS.FolderExists( sFolder ) Then
MsgBox "Cannot create " & sFolder & "; aborting..."
WScript.Quit( 1 )
End If
End If
End Sub
' where are we? ''''''''''''''''''''''''''''''''''''''''''''
sTemp = Wscript.ScriptFullName
sTLroot = oFS.GetParentFolderName( sTemp )
sTLrootSl = AddBsl(sTLroot)
sTLrootBin = sTLrootSl & "bin\win32"
' diagnostics '''''''''''''''''''''''''''''''''''''''''''''''
' check path for conflicting TeX
bTlOnPath = False
Err.Clear()
sTemp = ""
sTemp = FindOnPath( "pdftex.exe" )
If ( sTemp <> "" ) Then
' WARNING: the test below does not take short names into account!
If UCase( AddBsl( sTemp ) ) <> UCase( sTLrootBin & "\" ) Then
Wscript.Echo "Found another TeX in " & sTemp & ";" & vbNewLine & _
"Please uninstall this TeX or remove it from your search path." _
& vbNewLine & PathHelp
Wscript.Quit( 1 )
Else
bTlOnPath = True
End If
End If
' Find Ghostscript
' Ghostscript on path?
bGsFound = False
bGsOnPath = False
sGsRoot = ""
sGsRootParent = ""
sTemp = FindOnPath( "gswin32c.exe" )
If sTemp <> "" Then
' root of this version
sTemp = RemoveSl( sTemp )
sGsRoot = RemoveSl( oFS.GetParentFolderName( RemoveSl( sTemp ) ) )
sGsRootParent = RemoveSl(oFS.GetParentFolderName( sGsRoot ) )
bGsFound = True
bGsOnPath = True
End If
' if not, check registry.
' Have to do some guessing here.
' First try most attractive options
nGsVersion = 0
if Not bGsFound Then
For l = 999 to 800 step -1
For Each k in Array( "HKCU", "HKLM" )
For Each i in Array( "GPL", "GNU", "AFPL", "ESP" )
Err.Clear()
sTemp = oWsh.RegRead( _
k & "\software\" & i & " Ghostscript\" _
& num2version( l ) & "\GS_DLL" )
If ( Not Err ) and ( sTemp <> "" ) Then
sGsRoot = left( sTemp, _
len( sTemp ) - len( "\bin\gsdll32.dll" ) )
sGsRootParent = _
RemoveSl(oFS.GetParentFolderName( sGsRoot ) )
nGsVersion = l
bGsFound = True
Exit For
End If
Next
If nGsVersion > 0 Then Exit For
Next
If nGsVersion > 0 Then Exit For
Next
If not bGsFound Then
Wscript.Echo "No Ghostscript found." & vbNewLine & _
"Please run the Ghostscript " _
& "installer " & sTlRootSl & "support\gs854w32-tl.zip first," _
& vbNewLine & _
"or, if you do have Ghostscript, add it to the search path." _
& vbNewLine & PathHelp
Wscript.Quit( 1 )
End If
End If
' test for pre-installed Perl.
bPerlOnPath = False
sTemp = FindOnPath( "perl.exe" )
If ( sTemp <> "" ) and _
( UCase( AddBsl( sTemp ) ) <> UCase( sTLrootBin & "\" ) ) Then
bPerlOnPath = True
End If
' create directories '''''''''''''''''''''''''''''''''''''''''''
sTLmain = AddBsl( oWsh.expandenvironmentstrings( "%USERPROFILE%" ) ) & _
"TeXLive2007"
sTLocal = AddBsl( oWsh.expandenvironmentstrings( "%USERPROFILE%" ) ) & _
"texmf-local"
CreateTry sTLmain
CreateTry sTLmain & "\texmf-var"
CreateTry sTLmain & "\texmf-var\web2c"
oFS.CopyFile sTLrootSl & "texmf\web2c\texmf.cnf-4WIN", _
sTLmain & "\texmf-var\web2c\texmf.cnf"
oFS.CopyFile sTLrootSl & "texmf\web2c\fmtutil.cnf", _
sTLmain & "\texmf-var\web2c\fmtutil.cnf"
CreateTry sTLmain & "\texmf-var\tex"
CreateTry sTLmain & "\texmf-var\tex\generic"
CreateTry sTLmain & "\texmf-var\tex\generic\config"
oFS.CopyFile sTLrootSl & "texmf\tex\generic\config\language.dat", _
sTLmain & "\texmf-var\tex\generic\config\language.dat"
CreateTry sTLmain & "\temp"
CreateTry sTLocal
CreateTry sTLocal & "\doc"
CreateTry sTLocal & "\dvips"
CreateTry sTLocal & "\fonts"
CreateTry sTLocal & "\tex"
' additions to the search path '''''''''''''''''''''''''''''''''''
' Ghostscript and TeXLive are appended to the user searchpath,
' inasfar as necessary. A pre-installed Perl on the old path will
' automatically have priority.
sTemp = ""
If ( Not bTlOnPath ) Then
sTemp = sTLrootBin
End If
If Not bGsOnPath Then
If sTemp = "" Then
sTemp = sGsRoot & "\bin"
Else
sTemp = sTemp & ";" & sGsRoot & "\bin"
End If
End If
If Not sTemp = "" Then
Err.Clear()
sTemp2 = oWsh.RegRead( "HKCU\environment\path" )
If ( Not Err ) and ( sTemp2 <> "" ) Then
sTemp = sTemp2 & ";" & sTemp
End If
If InStr( 1, sTemp, "%" ) > 0 Then
oWsh.RegWrite "HKCU\Environment\Path", sTemp, "REG_EXPAND_SZ"
Else
oWsh.RegWrite "HKCU\Environment\Path", sTemp
End If
End If
' other environment settings ''''''''''''''''''''''''''''''''''''
' perl
If Not bPerlOnPath Then
oWsh.RegWrite "HKCU\environment\PERL5LIB", sTLrootSl & _
"perltl\lib;" & sTLrootSl & "perltl\site\lib"
End If
' Ghostscript; assume the usual Ghostscript directory layout
oWsh.RegWrite "HKCU\environment\GS_LIB", _
sGsRoot & "\lib;" & sGsRootParent & "\fonts;" & _
sGsRoot & "\Resource", "REG_SZ"
oWsh.RegWrite "HKCU\environment\GS_DLL", _
sGsRoot & "\bin\gsdll32.dll", "REG_SZ"
' TeXLive env vars
oWsh.RegWrite "HKCU\environment\TEXMFCNF", _
sTLmain & "\texmf-var\web2c"
oWsh.RegWrite "HKCU\environment\TEXMFTEMP", _
sTLmain & "\temp"
oWsh.RegWrite "HKCU\environment\TEXMFVAR", _
sTLmain & "\texmf-var"
oWsh.RegWrite "HKCU\environment\TEXMFLOCAL", _
sTLocal
oWsh.RegWrite "HKCU\environment\TLroot", sTLmain
' generate files
Set oFile = oFS.CreateTextFile( sTLmain & "\temp\tl_generate.bat" )
oFile.WriteLine( "@echo off" )
oFile.WriteLine( "path %path%;" & sTLrootSl & "bin\win32" )
oFile.WriteLine( "set TEXMFCNF=" & sTLmain & "\texmf-var\web2c" )
oFile.WriteLine( "set TEXMFTEMP=" & sTLmain & "\temp" )
oFile.WriteLine( "set TEXMFVAR=" & sTLmain & "\texmf-var" )
oFile.WriteLine( "set TEXMFLOCAL=" & sTLocal )
oFile.WriteLine( "set TLroot=" & sTLmain )
oFile.WriteLine( "mktexlsr" )
oFile.WriteLine( "updmap" )
oFile.WriteLine( "fmtutil --byfmt latex" )
'oFile.WriteLine( "fmtutil --all" )
oFile.WriteLine( "echo Done. Please re-login." )
oFile.WriteLine( "pause" )
oFile.close
oWsh.run """" & sTLmain & "\temp\tl_generate.bat" & """", 1, true
'oFS.deletefile( sTLmain & "\temp\tl_generate.bat" )
--
Siep Kroonenberg
More information about the tex-live
mailing list