标签:
以前用NSIS写的一个工具,现贴出源码。
!packhdr temp.dat ‘upx -9 temp.dat‘ ;!packhdr temp.dat ‘cmd /c Copy /B temp.dat /B +D:\Pro_Template\Pack_NSIS.7z temp.dat‘ !define PRO_NAME "CCTool-ACAD" !define PRO_VER "Final(NSIS)" ;NSIS最终版 !define VIPRO_VER "0.0.0.0" !define PRO_PUBLISH "171130508" !define PRO_ABOUTURL "http://ShowI90.blog.163.com/" !define /date PRO_DATE "%Y" BrandingText /TRIMCENTER "${PRO_ABOUTURL}" Caption "${PRO_NAME} ${PRO_VER}" InstallButtonText "开始清理(&N)" OutFile "${PRO_NAME}.exe" SetFont /LANG=2052 "新宋体" 12 ShowInstDetails show !include "FileFunc.nsh" !include "Locate.nsh" !include "MUI2.nsh" !include "Registry.nsh" !include "WordFunc.nsh" !define MUI_ICON "${PRO_NAME}.ico" !define MUI_UI "CleanUI.exe" ;!define MUI_LICENSEPAGE_TEXT_BOTTOM "请仔细阅读下面的说明及许可,您可以从它了解到本程序的功能以及一些注意事项。" ;!define MUI_LICENSEPAGE_BUTTON "明白了" ;!define MUI_LICENSEPAGE_CHECKBOX ;!define MUI_LICENSEPAGE_CHECKBOX_TEXT "我对程序的功能已经了解,并表示同意上诉的许可。" !define MUI_COMPONENTSPAGE_TEXT_TOP "请勾选需要清理的垃圾文件类型,但是请注意:这些垃圾文件将被直接删除,这意味着它们无法从回收站中被恢复。" !define MUI_CUSTOMFUNCTION_GUIINIT onGUIInit ;!insertmacro MUI_PAGE_LICENSE "License.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_LANGUAGE "SimpChinese" VIAddVersionKey /LANG=${LANG_SimpChinese} "ProductName" ${PRO_NAME} VIAddVersionKey /LANG=${LANG_SimpChinese} "Comments" "关于NSIS学习的终版,不更新了。" VIAddVersionKey /LANG=${LANG_SimpChinese} "CompanyName" "QQ:171130508" VIAddVersionKey /LANG=${LANG_SimpChinese} "LegalCopyright" "Copyright (C) ${PRO_DATE} ${PRO_PUBLISH}.All right reserved" VIAddVersionKey /LANG=${LANG_SimpChinese} "FileDescription" "定制清理工具—AutoCAD垃圾文件清理" VIAddVersionKey /LANG=${LANG_SimpChinese} "FileVersion" "${PRO_VER}" VIAddVersionKey /LANG=${LANG_SimpChinese} "ProductVersion" "${PRO_VER}" VIProductVersion ${VIPRO_VER} ReserveFile "${NSISDIR}\Plugins\System.dll" ReserveFile "${NSISDIR}\Plugins\Locate.dll" ReserveFile "${NSISDIR}\Plugins\nsRandom.dll" ReserveFile "${NSISDIR}\Plugins\UserInfo.dll" ReserveFile "${NSISDIR}\Plugins\BrandingURL.dll" Var FEX ;文件扩展名 Var ACAD_DDD ;.$$$ Var ACAD_DA ;.$a Var ACAD_ACD ;.ac$ Var ACAD_ADT ;.adt Var ACAD_BAK ;.bak Var ACAD_DCE ;.dce Var ACAD_DWL ;.dwl Var ACAD_DWL2 ;.dwl Var ACAD_ERR ;.err Var ACAD_FAS ;.fas Var ACAD_LOG ;.log Var ACAD_LSP ;.lsp Var ACAD_SVD ;.sv$ Var ACAD_VLX ;.vlx Var USER_NAME ;获取用户名 Var USER_STR ;用户字符串 Var USER_NUM ;用户数字 SectionGroup /e "常规清理(推荐)" Section /o ".$$$$$$ (AutoCAD 紧急备份图形)" acadddd IntOp $ACAD_DDD 0 + 1 SectionEnd Section /o ".$$a (AutoCAD 临时文件)" acadda IntOp $ACAD_DA 0 + 1 SectionEnd Section /o ".ac$$ (AutoCAD 临时文件)" acadacd IntOp $ACAD_ACD 0 + 1 SectionEnd Section /o ".adt (AutoCAD 核查日志)" acadadt IntOp $ACAD_ADT 0 + 1 SectionEnd Section /o ".bak (AutoCAD 图形副本文件)" acadbak IntOp $ACAD_BAK 0 + 1 SectionEnd Section /o ".dce (AutoCAD 对话框错误日志)" acaddce IntOp $ACAD_DCE 0 + 1 SectionEnd Section /o ".dwl (AutoCAD 图形临时文件)" acaddwl IntOp $ACAD_DWL 0 + 1 SectionEnd Section /o ".dwl2 (AutoCAD 图形临时文件)" acaddwl2 IntOp $ACAD_DWL2 0 + 1 SectionEnd Section /o ".err (AutoCAD 图形错误日志)" acaderr IntOp $ACAD_ERR 0 + 1 SectionEnd Section /o ".log (AutoCAD 打印记录文件)" acadlog IntOp $ACAD_LOG 0 + 1 SectionEnd Section /o ".sv$$ (AutoCAD 自动保存图形)" acadsvd IntOp $ACAD_SVD 0 + 1 SectionEnd SectionGroupEnd SectionGroup /e "可选清理(慎选)" Section /o ".fas (AutoCAD 快速加载 AutoLISP 文件)" acadfas IntOp $ACAD_FAS 0 + 1 SectionEnd Section /o ".lsp (AutoCAD 应用程序源代码)" acadlsp IntOp $ACAD_LSP 0 + 1 SectionEnd Section /o ".vlx (AutoCAD 应用程序源代码)" acadvlx IntOp $ACAD_VLX 0 + 1 SectionEnd SectionGroupEnd Section "-Search for text files" ${GetDrives} "HDD" "SearchFile" SectionEnd Function "SearchFile" DetailPrint "Search $9" ${locate::Open} $9 "/B=1 /D=0 /F=1 \ /X=$$$$$$|$$a|ac$$|adt|bak|dce|dwl|dwl2|err|fas|log|lsp|sv$$|vlx" $R0 StrCmp $R0 0 +1 loop MessageBox MB_OK "Error" IDOK close loop: ${locate::Find} $R0 $R1 $R2 $R3 $R4 $R5 $R6 StrLen $R7 $R1 IntCmpU $R7 0 close +1 ${WordFind} $R1 "." -1 $FEX Push $R1 StrCmp $FEX "$$$$$$" +1 +3 Call "CleanDDD" Goto loop StrCmp $FEX "$$a" +1 +3 Call "CleanDA" Goto loop StrCmp $FEX "ac$$" +1 +3 Call "CleanACD" Goto loop StrCmp $FEX "adt" +1 +3 Call "CleanADT" Goto loop StrCmp $FEX "bak" +1 +3 Call "CleanBAK" Goto loop StrCmp $FEX "dce" +1 +3 Call "CleanDCE" Goto loop StrCmp $FEX "dwl" +1 +3 Call "CleanDWL" Goto loop StrCmp $FEX "dwl2" +1 +3 Call "CleanDWL2" Goto loop StrCmp $FEX "err" +1 +3 Call "CleanERR" Goto loop StrCmp $FEX "fas" +1 +3 Call "CleanFAS" Goto loop StrCmp $FEX "log" +1 +3 Call "CleanLOG" Goto loop StrCmp $FEX "lsp" +1 +3 Call "CleanLSP" Goto loop StrCmp $FEX "SV$$" +1 +3 Call "CleanSVD" Goto loop StrCmp $FEX "VLX" +1 +2 Call "CleanVLX" Goto loop close: ${locate::Close} $R0 ${locate::Unload} StrCpy $0 "StopLocate" Push $0 FunctionEnd Function CleanDDD Pop $R9 IntCmpU $ACAD_DDD 1 +1 ret ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanDA" Pop $R9 IntCmpU $ACAD_DA 1 +1 ret ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanACD" Pop $R9 IntCmpU $ACAD_ACD 1 +1 ret ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanADT" Pop $R9 IntCmpU $ACAD_ADT 1 +1 ret ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanBAK" Pop $R9 IntCmpU $ACAD_BAK 1 +1 ret ret FileOpen $1 $R9 r FileRead $1 $USER_STR 2 FileRead $1 $USER_NUM 4 FileClose $1 StrCmpS $USER_STR "AC" +1 ret IntCmpU $USER_NUM 1014 clean ret +1 ;R14 IntCmpU $USER_NUM 1015 clean ret +1 ;2000 IntCmpU $USER_NUM 1018 clean ret +1 ;2004 IntCmpU $USER_NUM 1021 clean ret +1 ;2007 IntCmpU $USER_NUM 1024 clean ret +1 ;2010 IntCmpU $USER_NUM 1027 clean ret +1 ;2013 Goto +3 clean: Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanDCE" Pop $R9 IntCmpU $ACAD_DCE 1 +1 ret ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanDWL" Pop $R9 IntCmpU $ACAD_DWL 1 +1 ret ret UserInfo::GetName Pop $USER_NAME StrLen $2 $USER_NAME FileOpen $1 $R9 r FileRead $1 $USER_STR $2 FileClose $1 StrCmpS $USER_STR $USER_NAME +1 ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanDWL2" Pop $R9 IntCmpU $ACAD_DWL2 1 +1 ret ret FileOpen $1 $R9 r FileRead $1 $USER_STR 37 FileClose $1 StrCmpS $USER_STR ‘<?xml version="1.0" encoding="UTF-8">‘ +1 ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanERR" Pop $R9 IntCmpU $ACAD_ERR 1 +1 ret ret ${GetFileName} $R9 $1 StrCmp $1 "acad.err" +1 ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanFAS" Pop $R9 IntCmp $ACAD_FAS 1 +1 ret ret ${GetbaseName} $R9 $1 StrCpy $USER_STR $1 4 0 StrCmp $USER_STR "acad" +1 ret Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanLOG" Pop $R9 IntCmpU $ACAD_LOG 1 +1 ret ret ${GetBaseName} $R9 $USER_STR StrCmp $USER_STR "plot" +1 ret FileOpen $1 $R9 r FileRead $1 $USER_STR FileClose $1 ${WordFind} $USER_STR "," "+1" $1 StrCpy $USER_STR $1 "" -3 StrCmp $USER_STR "dwg" +1 +2 Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanLSP" Pop $R9 IntCmpU $ACAD_LSP 1 +1 ret ret ${GetbaseName} $R9 $1 StrCpy $USER_STR $1 4 0 StrCmp $USER_STR "acad" +1 ret FileOpen $1 $R9 r FileRead $1 $USER_STR 1 FileClose $1 StrCmp $USER_STR ‘;‘ +2 +1 Delete /REBOOTOK $R9 ret: FunctionEnd Function "CleanSVD" Pop $R9 IntCmpU $ACAD_SVD 1 +1 ret ret FileOpen $1 $R9 r FileRead $1 $USER_STR 2 FileRead $1 $USER_NUM 4 FileClose $1 StrCmpS $USER_STR "AC" +1 ret IntCmpU $USER_NUM 1014 clean ret +1 ;R14 IntCmpU $USER_NUM 1015 clean ret +1 ;2000 IntCmpU $USER_NUM 1018 clean ret +1 ;2004 IntCmpU $USER_NUM 1021 clean ret +1 ;2007 IntCmpU $USER_NUM 1024 clean ret +1 ;2010 IntCmpU $USER_NUM 1027 clean ret +1 ;2013 Goto ret clean: Delete /REBOOTOK $R9 ret: Return FunctionEnd Function "CleanVLX" Pop $R9 IntCmpU $ACAD_LSP 1 +1 ret ret ${GetbaseName} $R9 $1 StrCpy $USER_STR $1 4 0 StrCmp $USER_STR "acad" +1 ret FileOpen $1 $R9 r FileRead $1 $USER_STR 9 FileClose $1 StrCmp $USER_STR ‘VRTLIB-1L‘ +1 +2 Delete /REBOOTOK $R9 ret: FunctionEnd Function onGUIInit BrandingURL::Set /NOUNLOAD "255" "0" "0" "${PRO_ABOUTURL}" FunctionEnd Function .onGUIEnd BrandingURL::Unload FunctionEnd Function .onSelChange SectionGetFlags ${acadddd} $1 IntOp $0 0 + $1 SectionGetFlags ${acadda} $1 IntOp $0 $0 + $1 SectionGetFlags ${acadadt} $1 IntOp $0 $0 + $1 SectionGetFlags ${acadbak} $1 IntOp $0 $0 + $1 SectionGetFlags ${acaddce} $1 IntOp $0 $0 + $1 SectionGetFlags ${acaddwl} $1 IntOp $0 $0 + $1 SectionGetFlags ${acaddwl2} $1 IntOp $0 $0 + $1 SectionGetFlags ${acaderr} $1 IntOp $0 $0 + $1 SectionGetFlags ${acadfas} $1 IntOp $0 $0 + $1 SectionGetFlags ${acadlog} $1 IntOp $0 $0 + $1 SectionGetFlags ${acadlsp} $1 IntOp $0 $0 + $1 SectionGetflags ${acadsvd} $1 IntOp $0 $0 + $1 SectionGetflags ${acadvlx} $1 IntOp $0 $0 + $1 IntCmp $0 0 +1 +2 +2 Push 3 nsRandom::GetRandom Pop $R1 IntCmpU $R1 0 +1 ret +2 SectionSetFlags ${acadbak} 1 IntCmpU $R1 1 +1 ret +2 SectionSetFlags ${acaddwl} 1 IntCmpU $R1 2 +1 ret +2 SectionSetFlags ${acaderr} 1 IntCmpU $R1 3 +1 ret +2 SectionSetFlags ${acadlog} 1 ret: Return FunctionEnd
标签:
原文地址:http://www.cnblogs.com/xTaisx/p/5039603.html