📄 uninst.tcl
字号:
-callback onUITclDialogOk] \
[list button -title "Cancel" -name cancelButt \
-xpos 266 -ypos 197 -width 50 -height 14 \
-callback {windowClose uninstDlg}]]
}
proc onUITclDialogOk {} {
global uninst
global env
controlEnable uninstDlg.okButt 0
controlEnable uninstDlg.cancelButt 0
controlEnable uninstDlg.uninstAll 0
controlEnable uninstDlg.uninstPart 0
controlDestroy uninstDlg.message
controlCreate uninstDlg { label -name progressTag \
-xpos 117 -ypos 151 -width 197 -height 8 \
}
controlCreate uninstDlg { meter -center -name progress \
-xpos 117 -ypos 164 -width 199 -height 22 \
}
controlColorsSet uninstDlg.progress \
-background Blue -foreground Black
uninstInfoGet
uninstResource
uninstFile
if {"$uninst(mode)" == "part"} {
uninstBackup
}
set setupLog ""
if {"$uninst(mode)" == "all"} {
catch {file delete -force $uninst(WIND_BASE)/.wind/uninst}
catch {file delete -force $uninst(WIND_BASE)/.wind/license}
catch {file delete $uninst(WIND_BASE)/.wind}
catch {file delete $uninst(WIND_BASE)/setup.log}
if [catch {file delete $uninst(WIND_BASE)} error] {
incr uninst(errorCount)
}
} {
catch {
set setupLog [open $uninst(WIND_BASE)/setup.log "a+"]
foreach line [split $uninst(info) "\n"] {
if {"$line" != ""} {
puts $setupLog "[date]\tUninst\t$line"
}
}
file delete $uninst(zipFile)
}
}
controlDestroy uninstDlg.progress
controlDestroy uninstDlg.progressTag
if {$uninst(errorCount) > 0} {
set msg "Warning: Not all files/directories are removed. You may\
need to remove them manually. Press the OK button to exit."
if {"$setupLog" != ""} {
puts $setupLog "\tUninstall did not complete successfully."
}
} {
set msg "Uninstall completed successfully.\
Press the OK button to exit."
}
if {"$setupLog" != ""} {
puts $setupLog ""
close $setupLog
}
controlCreate uninstDlg { label -name message \
-xpos 117 -ypos 153 -width 199 -height 25 }
controlDestroy uninstDlg.okButt
controlValuesSet uninstDlg.message "$msg"
controlValuesSet uninstDlg.cancelButt "OK"
controlEnable uninstDlg.cancelButt 1
}
proc uninstResource {} {
global uninst
set folderList {}
set visitedList {}
foreach line $uninst(resList) {
incr uninst(currItem)
set percent [expr ($uninst(currItem) * 99) / $uninst(totalItem)]
meterUpdate $percent "Removing" "[lindex $line 0]..."
if {[lsearch $visitedList $line] == "-1"} {
lappend visitedList $line
switch [lindex $line 0] {
icon {
set folderName [lindex $line 1]
set iconName [lindex $line 2]
set common [lindex $line 3]
if [catch {setupItemDelete $folderName $iconName $common} \
err] {
print "cannot delete icon, $iconName: $err"
} {
print "deleted icon: $iconName"
}
}
folder {
# Need to remove all the icons first
lappend folderList $line
}
regkey {
set rootKey [lindex $line 1]
set key [lindex $line 2]
if [catch {sysRegistryKeyDelete $rootKey $key} err] {
print "cannot delete registry key, $key: $err"
} {
print "deleted registry key: $key"
}
}
regValue {
set rootKey [lindex $line 1]
set subKey [lindex $line 2]
set value [lindex $line 3]
if [catch {sysRegistryValueDelete $rootKey $subKey $value} \
err] {
print "cannot delete registry value, $value: $err"
} {
print "deleted registry value: $value"
}
}
service {
set serviceName [lindex $line 1]
if [catch {setupServiceStop $serviceName} err] {
print "cannot stop service, $serviceName: $err"
} {
print "stopped service: $serviceName"
}
if [catch {setupServiceRemove $serviceName} err] {
print "cannot delete service: $serviceName: $err"
} {
print "deleted service: $serviceName"
}
}
default {}
}
}
}
# now is time to remove all folders if any
foreach folder $folderList {
set folderName [lindex $folder 1]
set common [lindex $folder 2]
if [catch {setupGroupDelete $folderName $common} err] {
print "cannot delete folder: $folderName: $err"
} {
print "deleted folder: $folderName"
}
}
}
proc uninstUITclDialogInit {} {
global uninst
global argv
global env
applicationTitleSet "Tornado Uninstall"
if {$uninst(mode) == "none"} {
messageBox -stop "Cannot find the uninstall information."
windowClose uninstDlg
} elseif {$uninst(mode) == "all"} {
controlValuesSet uninstDlg.uninstAll 1
controlEnable uninstDlg.uninstPart 0
onUninstallAll
} {
controlValuesSet uninstDlg.uninstPart 1
onUninstallPart
}
}
proc dosTempDirGet {} {
global env
# Determine the "temp" directory
set uninstTemp "_TMP[pid]"
foreach elem [array names env] {
if {[string compare [string tolower $elem] "tmp"] == 0} {
set env(TMP) $env($elem)
}
if {[string compare [string tolower $elem] "temp"] == 0} {
set env(TEMP) $env($elem)
}
if {[string compare [string tolower $elem] "tmpdir"] == 0} {
set env(TMPDIR) $env($elem)
}
}
if {[info exists env(TEMP)] && [file isdir $env(TEMP)]} {
set TMP $env(TEMP)\\$uninstTemp
} elseif {[info exists env(TMP)] && [file isdir $env(TMP)]} {
set TMP $env(TMP)\\$uninstTemp
} elseif {[info exists env(TMPDIR)] && [file isdir $env(TMPDIR)]} {
set TMP $env(TMPDIR)\\$uninstTemp
} {
set TMP "C:\\$uninstTemp"
}
return $TMP
}
proc seedUninstall {} {
global env argv0 uninst
set env(TMP) [unixToDos [dosTempDirGet]]
set binDir [unixToDos "$uninst(WIND_BASE)\\host\\x86-win32\\bin"]
set uninstDir [unixToDos "$uninst(WIND_BASE)\\.wind\\uninst"]
set requiredFiles(mfc42.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
# create the batch file that will copy required files and invoke uitclsh.exe
catch {file mkdir $env(TMP)}
set tmpBatchFileName "$env(TMP)\\tmp[pid].bat"
if [catch {open $tmpBatchFileName w} tmpBatchFile] {
set error $tmpBatchFile
} {
if [catch {
# write the necessary commands to execute from within the batch file
foreach file [array names requiredFiles] {
puts $tmpBatchFile \
"copy $requiredFiles($file)\\$file $env(TMP)"
}
# set the environment variables that's needed for the uninst.tcl
puts $tmpBatchFile "set UI=UITcl"
puts $tmpBatchFile "set TMP="
puts $tmpBatchFile "set TMP=[dosToUnix $env(TMP)]"
if {"[setupWinVerGet]" == "WIN95"} {
puts $tmpBatchFile "set PATH=[setupWinDirGet]\\command;%PATH%"
}
set flag ""
if [info exists env(SETUP_DEBUG)] {
set flag "-C"
}
puts $tmpBatchFile "start /wait \
$env(TMP)\\uitclsh.exe $flag \
[dosToUnix $env(TMP)\\uninst.tcl] \
$uninst(WIND_BASE)"
puts $tmpBatchFile "cd \\"
if {"[setupWinVerGet]" == "WIN95"} {
puts $tmpBatchFile "deltree /Y $env(TMP)"
} {
puts $tmpBatchFile "rmdir /S /Q $env(TMP)"
}
close $tmpBatchFile
} errorX] {set error $errorX}
}
# now spawn the batch file
if ![info exists error] {
if [catch {processCreate -hidden $tmpBatchFileName $env(TMP)} errorX] {
set error $errorX
}
}
if [info exists error] {
messageBox "Error launching Setup program: $error"
return ""
}
}
########################################################################
#
# Common functions
#
proc date {} {
return [clock format [clock second] -format "%d-%b-%y.%H:%M"]
}
proc dosToUnix {path} {
regsub -all {\\} $path {/} newpath
return $newpath
}
proc unixToDos {path} {
regsub -all {/} $path {\\} newpath
return $newpath
}
proc print {msg} {
global env
if [info exists env(SETUP_DEBUG)] {
puts "$msg"
}
}
proc meterUpdate {percent tag1 tag2} {
global ctrlVals
global uninst
global env
set shortFileName [fileNameAppreviate $tag2]
if {"$env(UI)" == "TK"} {
setWidth $ctrlVals(meterWg) $percent
$ctrlVals(meterTagWg) config -text "$tag1 $shortFileName"
update
} elseif {"$env(UI)" == "UITcl"} {
controlValuesSet uninstDlg.progress $percent
controlValuesSet uninstDlg.progressTag "$tag1 $shortFileName"
uiEventProcess
} {
puts "$percent $tag1 $tag2"
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -