📄 uninst.tcl
字号:
#set requiredFiles(msvcp60.dll) $binDir
set requiredFiles(msvcp50.dll) $binDir
set requiredFiles(mfc42.dll) $binDir
set requiredFiles(uitclcontrols.dll) $binDir
set requiredFiles(msvcrt.dll) $binDir
set requiredFiles(pctree32.dll) $binDir
set requiredFiles(tcl.dll) $binDir
set requiredFiles(uitcl.dll) $binDir
set requiredFiles(setuptcl.dll) $binDir
set requiredFiles(uitclsh.exe) $binDir
set requiredFiles(uninst.tcl) $uninstDir
set requiredFiles(uninst.bmp) $uninstDir
set requiredFiles(wrsCW.dll) $binDir
set requiredFiles(t2UninstallCleanup.exe) $binDir
# create the batch file that will copy required files and invoke uitclsh.exe
catch {file mkdir $env(TMP)}
foreach file [array names requiredFiles] {
file copy -force $requiredFiles($file)\\$file $env(TMP)
if {![isUnix]} {
file attributes $env(TMP)\\$file -readonly 0
}
}
set version [setupWinVerGet]
set flag ""
if {[info exists env(SETUP_DEBUG)]} {
set flag "-C"
}
if [catch {processCreate \
"$env(TMP)\\uitclsh.exe $flag [dosToUnix $env(TMP)\\uninst.tcl] \
$uninst(WIND_BASE) [dosToUnix $env(TMP)]" $env(TMP)} error] {
puts $error
}
}
##############################################################################
#
# print - prints a message to the active console.
#
# SYNOPSIS
# print <nsg>
#
# PARAMETERS: msg - message to be printed.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc print {msg} {
global env
if {[info exists env(SETUP_DEBUG)]} {
puts "$msg"
}
}
##############################################################################
#
# uninstMeterUpdate - updates the meter display
#
# This procedure uses the percent passed to update the meter.
#
# SYNOPSIS
# uninstMeterUpdate <percent tag1 tag2>
#
# PARAMETERS:
# percent - number indicating percentage complete
# tag 1 - any informational string to display or null
# tag 2 - a second string to display or null
#
# RETURNS: N/A
#
# ERRORS: N/A
#
#
proc uninstMeterUpdate {percent tag1 tag2} {
global ctrlVals
global uninst
global env
set shortFileName [fileNameAbbreviate $tag2 30]
controlValuesSet uninstDlg.progress $percent
controlValuesSet uninstDlg.progressTag "$tag1 $shortFileName"
uiEventProcess
}
##############################################################################
#
# message - prints a message
#
# This procedure prints a message either in the form of a message box.
#
# SYNOPSIS
# message <msg>
#
# PARAMETERS: msg - any string
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc message {msg} {
global uninst
global env
messageBox -ok -information $msg
}
##############################################################################
#
# dialog - display a dialog UI
#
# This procedure
#
# SYNOPSIS
#
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc dialog {type title msg bitmap default} {
global env
switch $type {
re_ig_cancel {
switch [messageBox -abortretryignore -questionicon $msg] {
abort { return 2 }
retry { return 0 }
ignore { return 1 }
}
}
}
}
##############################################################################
#
# lastInstSessionInfoGet - retrieves infomation on the last install session
#
# This procedure retrieves and stores into uninst(info) strings which indicate
# what was installed during the last install session.
#
# SYNOPSIS
# lastInstSessionInfoGet
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc lastInstSessionInfoGet {} {
global uninst env
set zipFile \
[lindex [lsort -decreasing \
[glob -nocomplain $uninst(home)/data.???]] 0]
set saveDir [pwd]
cd $env(TMP)
catch {setupUnzip -o -qq $zipFile "installInfo"}
if {[file exists "installInfo"]} {
set f [open "installInfo" "r"]
set uninst(info) [read $f]
close $f
} else {
set uninst(info) "No previous install infomation to extract."
}
}
##############################################################################
#
# uninstInfoGet - unzips the installInfo from the zip files
#
# This procedure unzips previous installation information from the data.???
# file into the appropriate unist() array values.
#
# SYNOPSIS
# uninstInfoGet
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc uninstInfoGet {} {
global uninst
global env
set uninst(currItem) 1
set uninst(totalItem) 1
set uninst(resList) ""
set uninst(fileList) ""
set uninst(bakList) ""
beginWaitCursor
set uninstZipFileList \
[lsort -decreasing [glob -nocomplain $uninst(home)/data.???]]
if {"$uninst(mode)" == "part"} {
set uninst(zipFile) [lindex $uninstZipFileList 0]
uninstInfoGetHelper $uninst(zipFile)
} elseif {"$uninst(mode)" == "all"} {
foreach zipFile $uninstZipFileList {
uninstInfoGetHelper $zipFile
}
}
endWaitCursor
print "uninst(resList) = $uninst(resList)"
print "uninst(totalItem) = $uninst(totalItem)"
if {$uninst(useInputScript)} {
autoUninstLog "uninst(resList) = $uninst(resList)"
autoUninstLog "uninst(totalItem) = $uninst(totalItem)"
}
}
##############################################################################
#
# uninstInfoGetHelper - helper proc for uninstInfoGet
#
# This procedure is invoked by uninstInfoGet which then does all the work
# of initializing the uninst(fileList), uninst(bakList), and uninst(resList).
#
# SYNOPSIS
# uninstInfoGetHelper <zipFile>
#
# PARAMETERS: zipFile - the zipfile to search through for the information.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc uninstInfoGetHelper {zipFile} {
global uninst
global env
set saveDir [pwd]
cd $env(TMP)
catch {setupUnzip -o -qq $zipFile "install*"}
# Load the installed file list
if {[file exists "installFile"]} {
set f [open "installFile" "r"]
while {[gets $f line] != "-1"} {
if {"$line" != ""} {
lappend uninst(fileList) [split $line "\t"]
}
}
close $f
}
# Load the backup file list
if {[file exists "installBackup"]} {
set f [open "installBackup" "r"]
while {[gets $f line] != "-1"} {
if {"$line" != ""} {
lappend uninst(bakList) [split $line "\t"]
}
}
close $f
}
# Load the resource file list
if {[file exists "installResource"]} {
set f [open "installResource" "r"]
while {[gets $f line] != "-1"} {
if {"$line" != ""} {
lappend uninst(resList) [split $line "\t"]
}
}
close $f
}
incr uninst(totalItem) [llength $uninst(fileList)]
incr uninst(totalItem) [llength $uninst(resList)]
if {"$uninst(mode)" == "part"} {
incr uninst(totalItem) [llength $uninst(bakList)]
}
cd $saveDir
}
##############################################################################
#
# uninstBackup - restores the file in the backup list
#
# This procedure restores the files from the $uninst(zipFile) zipfile.
#
# SYNOPSIS
# uninstBackup
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc uninstBackup {} {
global uninst
global env
foreach line $uninst(bakList) {
set file [lindex $line 1]
switch [lindex $line 0] {
wind_base {
incr uninst(currItem)
set percent [expr ($uninst(currItem) * 99) / $uninst(totalItem)]
uninstMeterUpdate $percent "Restoring " $file
if {[catch {setupUnzip -o -qq $uninst(zipFile) \
-d $uninst(WIND_BASE) $file} error]} {
incr uninst(errorCount)
message "Cannot restore $file: $error"
}
}
default { puts "unknown rootdir token" }
}
}
}
##############################################################################
#
# dirInsert - inserts the head directory of the path into array dirArray().
#
# SYNOPSIS
# dirInsert <pathName>
#
# PARAMETERS: pathname - path from which to extract the head of the tree.
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc dirInsert {pathName} {
global dirArray
set dirArray($pathName) ""
while { 1 } {
set pathName [file dirname $pathName]
if {$pathName == "."} {
break
} else {
set dirArray($pathName) ""
}
}
}
##############################################################################
#
# dirRemove - removes the directories listed in the tcl array dirArray().
#
# SYNOPSIS
# dirRemove
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc dirRemove {} {
global dirArray uninst
# delete the innermost empty directory first
foreach dir [lsort -decreasing [array names dirArray]] {
catch {file delete $uninst(WIND_BASE)/$dir}
}
}
##############################################################################
#
# uninstFile - removes the files and directories to be uninstalled.
#
# This procedure is the main procedure which coordinates the removal of the
# list of files and directories that are to be uninstalled.
#
# SYNOPSIS
# uninstFile
#
# PARAMETERS: N/A
#
# RETURNS: N/A
#
# ERRORS: N/A
#
proc uninstFile {} {
global uninst
global env
foreach line $uninst(fileList) {
set file [lindex $line 1]
switch [lindex $line 0] {
wind_base {
set filePath $uninst(WIND_BASE)/$file
dirInsert [file dirname $file]
}
window {
if {[file extension $file] == ".CPL"} {
catch {setupWindowClose "Control Panel"}
}
set filePath [setupWinDirGet]/$file
}
default { puts "unknown rootdir [lindex $line 0]" }
}
incr uninst(currItem)
set percent [expr ($uninst(currItem) * 99) / $uninst(totalItem)]
uninstMeterUpdate $percent "Removing " $file
if {[file exists $filePath]} {
while {[catch {file delete $filePath} error]} {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -