Changes
Maple
,no edit summary
<check type="uninstall" condition="exists" path="Maple %version% (Maple %version%)" />
<chain package-id="maple14.01" />
<variable name="path_reorder_exe" value="\\mathsdom\netlogon\scripts\system_path_reorder\path_reorder.exe" />
<install cmd='"%SOFTWARE%\math_progs\maple\Windows\Disk1\InstData\VM\Maple%version%WindowsInstaller.exe" -f "%SOFTWARE%\math_progs\maple.answer"' />
<install cmd='"%path_reorder_exe%" begin system32 env' />
<upgrade cmd='"%PROGRAMFILES%\Maple %version%\uninstall\Uninstall Maple %version%.exe" -i silent' />
<upgrade cmd='"%SOFTWARE%\math_progs\maple\Windows\Disk1\InstData\VM\Maple%version%WindowsInstaller.exe" -f "%SOFTWARE%\math_progs\maple.answer"' />
<upgrade cmd='"%path_reorder_exe%" begin system32 env' />
<remove cmd='"%PROGRAMFILES%\Maple %version%\uninstall\Uninstall Maple %version%.exe" -i silent' />
<remove cmd='%COMSPEC% /c rd /s /q "%PROGRAMFILES%\Maple %version%"'>
<exit code='any' />
</remove>
<remove cmd='%COMSPEC% /c rd /s /q "%SYSTEMDRIVE%\watcom-1.3"'>
<exit code='any' />
</remove>
<variable name="version" value="14"/>
<variable name="update" value="01" />
<variable name="path_reorder_exe" value="\\mathsdom\netlogon\scripts\system_path_reorder\path_reorder.exe" />
<!--<check type="file" condition="versionequalto" path="%PROGRAMFILES%\Maple 14\bin.win\maple.exe" value="1.0.0.1" />-->
<check type="file" condition="exists" path="%PROGRAMFILES%\Maple %version%\bin.win\maplew.exe.%version%.%update%" />
<!-- Now install the update... -->
<install cmd='%COMSPEC% /c start "" /wait "\\%DOMAIN%\netlogon\scripts\matlab_installer\matlab_install_wpkg.exe" "%SOFTWARE%\math_progs\maple\Maple1401WindowsUpgrade.exe" -f "%SOFTWARE%\math_progs\maple.answer" 4' />
<install cmd='"%path_reorder_exe%" begin system32 env' />
<!-- First make a backup of the original maplew.exe file. This is used for the <remove /> part of this file as there isn't
<upgrade cmd='%COMSPEC% /c copy /y "%PROGRAMFILES%\Maple %version%\bin.win\maplew.exe" "%PROGRAMFILES%\Maple %version%\bin.win\maplew.exe.%version%.%update%"' />
<upgrade cmd='%COMSPEC% /c start "" /wait "\\%DOMAIN%\netlogon\scripts\matlab_installer\matlab_install_wpkg.exe" "%SOFTWARE%\math_progs\maple\Maple1401WindowsUpgrade.exe" -f "%SOFTWARE%\math_progs\maple.answer" 4' />
<upgrade cmd='"%path_reorder_exe%" begin system32 env' />
<remove cmd='%COMSPEC% /c del /q "%PROGRAMFILES%\Maple %version%\bin.win\maplew.exe.%version%.%update%"' />
Return $avProcs
EndFunc ;==>_ProcessListProperties
</pre>
==System %PATH% re-order, Maple install screws it up==
When Maple is installed, it adds to the system %PATH% (C:\watcom-1.3\binnt;C:\watcom-1.3\binw). Normally this isn't a problem but for Maple it is as Maple installed a command sc.exe. Windows also has an sc.exe command for controlling services. Maple adds its additions to the beginning of %PATH% therefore when you try to change/add/delete a Windows service with sc, you get an error like:
<pre>
DOS/32A -- Protected Mode Run-time Version 7.2
Copyright (C) Supernar Systems, Ltd. 1996-2002
SC/32A fatal: DOS/32A environment variable is not set up properly
You need to reinstall DOS/32 Advanced DOS Extender on this computer
</pre>
This is because the Maple sc.exe is trying to run. To overcome this, another Autoit exe is ran (path_reorder.exe) after maple has installed to arrange the order of %PATH% and write the change to the %PATH% registry key that will get read in at next login. In the XML above, I've sorted %PATH% with anything with *system32% to be placed at the beginning of the %PATH% line. path_reorder.exe allows you to move all matches of the search string to the beginning or the end of %PATH% or to delete them from %PATH%. It also reads %PATH% from the environment variable or by reading the registry value.
<pre>
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=path_reorder.exe
#AutoIt3Wrapper_Res_Fileversion=0.0.0.14
#AutoIt3Wrapper_Res_FileVersion_AutoIncrement=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Array.au3>
; ***********************************************************************************************************************
;
; Script to remove from or move a requested search string to the end or to the beginning of the %PATH% system variable registry entry.
; A log out and in is required to pick up the change (unless anyone else knows how to do this 'on the fly'
;
; C.Mortimer@damtp.cam.ac.uk April 2011
;
; ***********************************************************************************************************************
If $Cmdline[0] < 3 Then
_help()
Exit
Else
$arg1 = StringLower($Cmdline[1])
$string2search4 = StringLower($Cmdline[2])
$env_or_reg = StringLower($Cmdline[3])
EndIf
If ($arg1 = "remove") OR ($arg1 = "end") OR ($arg1 = "begin") Then
If ($env_or_reg = "env") OR ($env_or_reg = "reg") Then
;
Else
_help()
Exit
EndIf
Else
_help()
Exit
EndIf
$reg_key = "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"
If $env_or_reg = "env" Then
$path_env_or_reg = EnvGet("PATH")
ElseIf $env_or_reg = "reg" Then
$path_env_or_reg = RegRead($reg_key, "Path")
EndIf
$path_array = StringSplit($path_env_or_reg, ";")
$array_search = _ArraySearch($path_array, $string2search4, "", "", "", 1)
If $arg1 = "end" Then ; move to the end section
$r = 0
$log = ""
For $i = 1 To $path_array[0] - 1 Step 1
If StringInStr($path_array[$i], $string2search4) Then
Do
If StringInStr($path_array[$path_array[0] - $r], $string2search4) Then
$log = $log & "," & $path_array[0] - $r & "," & $i ; make a note of the array elements already swapped, we don't want to swap these again.
$r = $r + 1
EndIf
Until StringInStr($path_array[0] - $r, $string2search4) = 0
$log = $log & "," & $r ; make a note of the array element number
If StringInStr($log, $i) Then
;~ ConsoleWrite("ALL READY SWAPPED" & @CRLF)
Else
$log = $log & "," & $path_array[0] - $r & "," & $i ; make a note of the array elements already swapped, we don't want to swap these again.
_ArraySwap($path_array[$i], $path_array[$path_array[0] - $r])
$r = $r + 1
EndIf
EndIf
Next
ElseIf $arg1 = "begin" Then ; move to the beginning section
$r = 0
$log = ""
For $i = $path_array[0] To 1 Step -1
If StringInStr($path_array[$i], $string2search4) Then
Do ; lets work out the next incrementing array NOT containing our search string
If StringInStr($path_array[1 + $r], $string2search4) Then
$log = $log & "," & $r ; make a note of the array element number
$r = $r + 1
EndIf
Until StringInStr($path_array[1 + $r], $string2search4) = 0
$log = $log & "," & $r ; make a note of the array element number
If StringInStr($log, $i) Then
;~ ConsoleWrite("ALL READY SWAPPED" & @CRLF)
Else
_ArraySwap($path_array[$i], $path_array[1 + $r])
$r = $r + 1
EndIf
EndIf
Next
ElseIf $arg1 = "remove" Then ; remove from the PATH
Do
$array_search = _ArraySearch($path_array, $string2search4, "", "", "", 1)
_ArrayDelete($path_array, $array_search)
Until _ArraySearch($path_array, $string2search4, "", "", "", 1) = -1
Else
;
EndIf
$new_path = _ArrayToString($path_array, ";", 1)
If $path_env_or_reg = $new_path Then
;
Else
RegWrite($reg_key, "Path_pre_reorder", "REG_EXPAND_SZ", $path_env_or_reg)
If StringLeft($new_path, 1) = ";" Then $new_path = StringTrimLeft($new_path, 1)
RegWrite($reg_key, "Path", "REG_EXPAND_SZ", $new_path)
ConsoleWrite($new_path & @CRLF)
EndIf
Func _help()
ConsoleWrite(@CRLF & @CRLF & "Usage" & @CRLF & @CRLF & "Script to be used by WPKG to reorder/remove items out of the System PATH setting." & @CRLF & @CRLF & _
"Three arguments are required. The first argument is either 'remove', 'end' or 'begin'. The second argument is the string, full or partical, of " & _
"the item you want to remove, move to the end of the 'PATH' string or move to the beginning of the path string. Any parts of the existing 'PATH', " & _
"semi-colon seperated, matching the second argument will be deleted/moved. The third is either 'env' or 'reg'. 'env' = read in and manipulate " & _
"the 'PATH' environment variable. 'reg' reads in the subkey 'PATH' registry entry at HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\" & _
"Environment." & @CRLF & @CRLF & "This script returns the new path to the cmd line and sets the registry subkey. The 'PATH' is read in at next login." & _
@CRLF & @CRLF & "E.g." & @CRLF & @ScriptName & " remove miktex env = remove any parts of the environment variable 'PATH' with *miktex* in." & _
@CRLF & @CRLF & @ScriptName & " end miktex reg = move any parts of the 'PATH' registry subkey with *miktex* to the end of the " & _
" registry 'PATH' subkey" & @CRLF & @CRLF & @ScriptName & " begin miktex env = move any parts of the environment variable 'PATH' with *miktex* to the " & _
"beginning of the registry 'PATH' subkey" & @CRLF & @CRLF & _
"C. Mortimer April 2011" & @CRLF)
EndFunc ;==>_help
</pre>
[[Category: Silent Installers]]