- 積分
- 4130
- 最後登入
- 1970-1-1
- 閱讀權限
- 255
- 積分
- 4130
- 帖子
- 精華
升級
100%
|
本帖最後由 gary8349 於 2016-10-6 21:53 編輯
AutoRun.au3- #cs ____________________________________
- Au3版本:3.14.2
- SciTE版本:3.6.6
- 腳本作者:Grayfree
- 腳本功能:
- 參考代碼:Dang Wang
- #ce _______________腳本開始_________________
- #NoTrayIcon
- #RequireAdmin
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #include <Misc.au3>
- ;;防止重複執行
- _Singleton ( @ScriptName )
- #cs _______________用檔案總管複製檔案_______________
- Global Const $FO_COPY = 0x0002
- Global Const $FOF_ALLOWUNDO = 0x0040
- _ExplorerCopy ( "AutoIt3" , $AURUT )
- Func _ExplorerCopy($source, $dest)
- Local $SHFILEOPSTRUCT, $source_struct, $dest_struct
- $SHFILEOPSTRUCT = DllStructCreate("hwnd hWnd;uint wFunc;ptr pFrom;ptr pTo;int fFlags;" & _
- "int fAnyOperationsAborted;ptr hNameMappings;ptr lpszProgressTitle")
- $source_struct = DllStructCreate("char[" & StringLen($source) + 2 & "]")
- DllStructSetData($source_struct, 1, $source)
- DllStructSetData($source_struct, 1, 0, StringLen($source) + 2)
- $dest_struct = DllStructCreate("char[" & StringLen($dest) + 2 & "]")
- DllStructSetData($dest_struct, 1, $dest)
- DllStructSetData($dest_struct, 1, 0, StringLen($dest) + 2)
- DllStructSetData($SHFILEOPSTRUCT, "hWnd", 0)
- DllStructSetData($SHFILEOPSTRUCT, "wFunc", $FO_COPY)
- DllStructSetData($SHFILEOPSTRUCT, "pFrom", DllStructGetPtr($source_struct))
- DllStructSetData($SHFILEOPSTRUCT, "pTo", DllStructGetPtr($dest_struct))
- DllStructSetData($SHFILEOPSTRUCT, "fFlags", $FOF_ALLOWUNDO)
- DllCall("shell32.dll", "int", "SHFileOperation", "ptr", DllStructGetPtr($SHFILEOPSTRUCT))
- EndFunc ;==>_ExplorerCopy
- #ce _______________用檔案總管複製檔案_______________
- ;;宣告安裝路徑
- Dim Const $AURUT = @ProgramFilesDir & "\AutoIt3"
- ;;宣告時間變數,用於建立資料夾或檔名
- Dim $DateTime = ( @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & [url=home.php?mod=space&uid=7364572]@min[/url] & "_" & @SEC )
- ;;終止進程
- If ProcessExists ( "AutoDec19.exe" ) Then
- ProcessClose ( "AutoDec19.exe" )
- EndIf
- If ProcessExists ( "AutoIt代碼簡易格式化工具.exe" ) Then
- ProcessClose ( "AutoIt代碼簡易格式化工具.exe" )
- EndIf
- If ProcessExists ( "Reg2Au3(UniCode).exe" ) Then
- ProcessClose ( "Reg2Au3(UniCode).exe" )
- EndIf
- If ProcessExists ( "Reg2Au3(ANSI).exe" ) Then
- ProcessClose ( "Reg2Au3(ANSI).exe" )
- EndIf
- If ProcessExists ( "Au3Info.exe" ) Then
- ProcessClose ( "Au3Info.exe" )
- EndIf
- If ProcessExists ( "SciTE.exe" ) Then
- ProcessClose ( "SciTE.exe" )
- EndIf
- If ProcessExists ( "Aut2exe.exe" ) Then
- ProcessClose ( "Aut2exe.exe" )
- EndIf
- If ProcessExists ( "FD.exe" ) Then
- ProcessClose ( "FD.exe" )
- EndIf
- If ProcessExists ( "hh.exe" ) Then
- ProcessClose ( "hh.exe" )
- EndIf
- ;;判斷是否安裝過
- If FileExists ($AURUT & "\Include" ) or FileExists ($AURUT & "\SciTE" ) or FileExists ($AURUT & "\Examples" ) Then
- If MsgBox (4609, "已有安裝AutoIt" , "按下確定開始安裝AutoIt" & @CRLF & "按下取消離開安裝程式" ) <> 1 Then
- Exit
- Else
- ;;繼續安裝,覆蓋前備份設定檔和UDF
- $BakFolder = @HomeDrive & "\AutoIt_Config_Backup" & "\Installer_Backup_" & $DateTime
- DirCreate ( $BakFolder & "\Include" )
- DirCopy ( $AURUT & "\Include" , $BakFolder & "\Include" , 0x00000001 )
- FileCopy ( $AURUT & "\SciTE\SciTE.sess" , $BakFolder )
- FileCopy ( $AURUT & "\SciTE\SciTEUser.properties" , $BakFolder )
- MsgBox (0 , "提示" , "覆寫原有檔案前," & @CRLF & "" & @CRLF & "已將設定檔和UDF備份至:" & @CRLF & $BakFolder )
- EndIf
- EndIf
- ;;全新安裝詢問
- If FileExists ($AURUT & "\Include" ) or FileExists ($AURUT & "\SciTE" ) or FileExists ($AURUT & "\Examples" ) Then
- Else
- If MsgBox (4609, "安裝AutoIt" , "是否要全新安裝 AutoIt v3" ) <> 1 Then
- Exit
- EndIf
- EndIf
- ;;建立工作中提示窗
- GUICreate ( "執行中" , 200 , 72 , Default , Default , BitOR ( $WS_SYSMENU , $WS_POPUP ) ) ; 建立無邊框GUI視窗
- GUISetState ( @SW_SHOW) ; 顯示GUI視窗
- $Label1 = GUICtrlCreateLabel ("- 安裝中,請稍候 -" , 50 , 32 , 100 , 25 )
- GUICtrlSetColor ( -1 , 0x1260FF ) ;;藍色
- ;;複製資料夾到目的地
- DirCopy ( "AutoIt3" , $AURUT , 0x00000001 )
- ;;建立開始桌面捷徑
- FileCreateShortcut ( $AURUT & "\AutoDec19.exe" , @DesktopDir & "\AutoIt 反編譯工具.lnk" )
- FileCreateShortcut ( $AURUT & "\AutoIt代碼簡易格式化工具.exe" , @DesktopDir & "\AutoIt 代碼簡易格式化工具.lnk" )
- FileCreateShortcut ( $AURUT & "\Reg2Au3(UniCode).exe" , @DESKTOPDIR & "\Reg2Au3(UniCode).lnk" )
- FileCreateShortcut ( $AURUT & "\Au3Info.exe" , @DESKTOPDIR & "\Au3Info.lnk" )
- FileCreateShortcut ( $AURUT & "\SciTE\SciTE.exe" , @DESKTOPDIR & "\SciTE.lnk" )
- FileCreateShortcut ( $AURUT & "\Aut2Exe\Aut2exe.exe" , @DESKTOPDIR & "\Aut2exe.lnk" )
- FileCreateShortcut ( $AURUT & "\KODA FormDesigner 1.6.0.2\FD.exe" , @DESKTOPDIR & "\KODA FormDesigner .lnk" )
- ;;建立開始功能表捷徑
- $Path = @UserProfileDir & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\AutoIt v3"
- DirCreate ( $Path )
- FileCreateShortcut ( $AURUT & "\AutoDec19.exe" , $Path & "\_AutoIt 反編譯工具.lnk" )
- FileCreateShortcut ( $AURUT & "\AutoIt代碼簡易格式化工具.exe" , $Path & "\_AutoIt 代碼簡易格式化工具.lnk" )
- FileCreateShortcut ( $AURUT & "\AutoIt_3.3.0.0_繁中.chm" , $Path & "\_AutoIt 幫助手冊 3.3.0.0 繁中版.lnk" )
- FileCreateShortcut ( $AURUT & "\AutoIt.chm" , $Path & "\_AutoIt 幫助手冊 3.3.14.2 英文版.lnk" )
- FileCreateShortcut ( $AURUT & "\Reg2Au3(UniCode).exe" , $Path & "\Reg2Au3(UniCode).lnk" )
- FileCreateShortcut ( $AURUT & "\Au3Info.exe" , $Path & "\Au3Info.lnk" )
- FileCreateShortcut ( $AURUT & "\SciTE\SciTE.exe" , $Path & "\SciTE.lnk" )
- FileCreateShortcut ( $AURUT & "\Aut2Exe\Aut2exe.exe" , $Path & "\Aut2exe.lnk" )
- FileCreateShortcut ( $AURUT & "\KODA FormDesigner 1.6.0.2\FD.exe" , $Path & "\KODA FormDesigner.lnk" )
- FileCreateShortcut ( $AURUT & "\Uninstall.exe" , $Path & "\反安裝 AutoIt v3.lnk" )
- FileCreateShortcut ( $AURUT & "\Examples" , $Path & "\_Example" )
- DirCreate ( $Path & "\Extras" )
- DirCreate ( $Path & "\Extras\AutoItX" )
- FileCreateShortcut ( $AURUT & "\AutoIt v3 Website.url" , $Path & "\Extras\AutoIt v3 Website.url" )
- FileCreateShortcut ( $AURUT & "\Extras" , $Path & "\Extras\瀏覽 Extras 資料夾" )
- FileCreateShortcut ( $AURUT & "\AutoItX\AutoItX.chm" , $Path & "\Extras\AutoItX\AutoItX Help File.lnk" )
- FileCreateShortcut ( $AURUT & "\AutoItX\ActiveX\VBScript" , $Path & "\Extras\AutoItX\VBScript 範例" )
- ;;複製設定檔
- FileCopy ( "SciTE.session" , $AURUT & "\SciTE\SciTE.sess" )
- FileCopy ( "SciTEUser.properties" , $AURUT & "\SciTE\SciTEUser.properties" )
- ;;複製移除用檔案
- FileCopy ( "Uninstall.exe" , $AURUT , 1 )
- ;;建立官方安裝後會有的登錄表
- RegWrite ( "HKEY_CLASSES_ROOT\.au3" , "PerceivedType" , "REG_SZ" , "text" )
- RegWrite ( "HKEY_CLASSES_ROOT\.au3", "", "REG_SZ", "AutoIt3Script")
- RegWrite ( "HKEY_CLASSES_ROOT\.au3\PersistentHandler", "", "REG_SZ", "{5e941d80 - bf96 - 11cd - b579 - 08002b30bfeb}")
- RegWrite ( "HKEY_CLASSES_ROOT\.au3\ShellNew", "FileName", "REG_SZ", "Template.au3")
- RegWrite ( "HKEY_CLASSES_ROOT\.a3x", "", "REG_SZ", "AutoIt3XScript")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script", "", "REG_SZ", "AutoIt v3 Script")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\DefaultIcon", "", "REG_SZ", $AURUT & "\Icons\au3script_v10.ico")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell", "", "REG_SZ", "Open")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Compile", "", "REG_SZ", "Compile Script")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Compile\Command", "", "REG_SZ", StringFormat('"%s\Aut2Exe\Aut2Exe.exe" / in "%l"', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX64", "", "REG_SZ", "Compile Script (x64)")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX64\Command", "", "REG_SZ", StringFormat('"%s\Aut2Exe\Aut2Exe_x64.exe" / in "%l"', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX86", "", "REG_SZ", "Compile Script (x86)")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\CompileX86\Command", "", "REG_SZ", StringFormat('"%s\Aut2Exe\Aut2Exe.exe" / in "%l"', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Edit", "", "REG_SZ", "Edit Script")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Edit\Command", "", "REG_SZ", StringFormat('"%s\SciTE\SciTE.exe" "%1"', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Open", "", "REG_SZ", "Open")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Open\Command", "", "REG_SZ", StringFormat('"%s\SciTE\SciTE.exe" "%1"', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Run", "", "REG_SZ", "Run Script")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Run\Command", "", "REG_SZ", StringFormat('"%s\AutoIt3.exe" "%1" % * ', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX64", "", "REG_SZ", "Run Script (x64)")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX64\Command", "", "REG_SZ", StringFormat('"%s\AutoIt3_x64.exe" "%1" % * ', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX86", "", "REG_SZ", "Run Script (x86)")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3Script\Shell\RunX86\Command", "", "REG_SZ", StringFormat('"%s\AutoIt3.exe" "%1" % * ', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3XScript", "", "REG_SZ", "AutoIt v3 Encoded Script")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3XScript\DefaultIcon", "", "REG_SZ", $AURUT & "\Icons\au3script_v10.ico")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3XScript\Shell", "", "REG_SZ", "Run")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3XScript\Shell\Run", "", "REG_SZ", "Run Script")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoIt3XScript\Shell\Run\Command", "", "REG_SZ", StringFormat('"%s\AutoIt3.exe" "%1" % * ', $AURUT))
- RegWrite ( "HKEY_CLASSES_ROOT\AutoItX3.Control", "", "REG_SZ", "AutoItX3 Class")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoItX3.Control\CLSID", "", "REG_SZ", "{1A671297 - FA74 - 4422 - 80FA - 6C5D8CE4DE04}")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoItX3.Control\CurVer", "", "REG_SZ", "AutoItX3.Control.1")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoItX3.Control.1", "", "REG_SZ", "AutoItX3 Class")
- RegWrite ( "HKEY_CLASSES_ROOT\AutoItX3.Control.1\CLSID", "", "REG_SZ", "{1A671297 - FA74 - 4422 - 80FA - 6C5D8CE4DE04}")
- ;;讓REG即時生效
- ProcessClose ( "explorer.exe" )
- Sleep ( 2000 )
- If ProcessExists ( "explorer.exe" ) Then
- MsgBox (0 , "提示" , "AutoIt 安裝已完成" )
- Else
- Run ( "explorer.exe" )
- MsgBox (0 , "提示" , "AutoIt 安裝已完成" )
- EndIf
複製代碼 Uninstall.au3- #cs ____________________________________
- Au3版本:3.14.2
- SciTE版本:3.6.6
- 腳本作者:Grayfree
- 腳本功能:
- 參考代碼:Dang Wang
- #ce _______________腳本開始_________________
- #NoTrayIcon
- #RequireAdmin
- #include <GUIConstantsEx.au3>
- #include <WindowsConstants.au3>
- #Include <Misc.au3>
- ;;防止重複執行
- _Singleton ( @ScriptName )
- ;;宣告檔案路徑
- Dim Const $AURUT = @ProgramFilesDir & "\AutoIt3"
- Dim Const $Path = @UserProfileDir & "\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\AutoIt v3"
- Dim $DateTime = ( @YEAR & "_" & @MON & "_" & @MDAY & "_" & @HOUR & "_" & @MIN & "_" & @SEC )
- ;;詢問是否移除
- If FileExists ($AURUT & "\Include" ) or FileExists ($AURUT & "\SciTE" ) or FileExists ($AURUT & "\Examples" ) Then
- If MsgBox (4609, "提示" , "確定要完整移除 AutoIt?" & @CRLF & "按下確定開始移除程式" & @CRLF & "" & @CRLF & "提醒:移除前記得備份UDF和設定檔喔~" ) <> 1 Then
- Exit
- EndIf
- EndIf
- ;;建立工作中提示窗
- GUICreate ( "執行中" , 200 , 72 , Default , Default , BitOR ( $WS_SYSMENU , $WS_POPUP ) ) ; 建立無邊框GUI視窗
- GUISetState ( @SW_SHOW) ; 顯示GUI視窗
- $Label1 = GUICtrlCreateLabel ("- 移除中,請稍候 -" , 50 , 32 , 100 , 25 )
- GUICtrlSetColor ( -1, 0xEE7600);;橘色
- ;;終止進程
- If ProcessExists ( "AutoDec19.exe" ) Then
- ProcessClose ( "AutoDec19.exe" )
- EndIf
- If ProcessExists ( "AutoIt代碼簡易格式化工具.exe" ) Then
- ProcessClose ( "AutoIt代碼簡易格式化工具.exe" )
- EndIf
- If ProcessExists ( "Reg2Au3(UniCode).exe" ) Then
- ProcessClose ( "Reg2Au3(UniCode).exe" )
- EndIf
- If ProcessExists ( "Reg2Au3(ANSI).exe" ) Then
- ProcessClose ( "Reg2Au3(ANSI).exe" )
- EndIf
- If ProcessExists ( "Au3Info.exe" ) Then
- ProcessClose ( "Au3Info.exe" )
- EndIf
- If ProcessExists ( "SciTE.exe" ) Then
- ProcessClose ( "SciTE.exe" )
- EndIf
- If ProcessExists ( "Aut2exe.exe" ) Then
- ProcessClose ( "Aut2exe.exe" )
- EndIf
- If ProcessExists ( "FD.exe" ) Then
- ProcessClose ( "FD.exe" )
- EndIf
- If ProcessExists ( "hh.exe" ) Then
- ProcessClose ( "hh.exe" )
- EndIf
- ;;備份設定檔和UDF至C:\
- $BakFolder = @HomeDrive & "\AutoIt_Config_Backup" & "\Remove_Backup_" & $DateTime
- DirCreate ( $BakFolder & "\Include" )
- DirCopy ( $AURUT & "\Include" , $BakFolder & "\Include" , 0x00000001 )
- FileCopy ( $AURUT & "\SciTE\SciTE.sess" , $BakFolder )
- FileCopy ( $AURUT & "\SciTE\SciTEUser.properties" , $BakFolder )
- ;;移除捷徑
- DirRemove ( $Path , 1 )
- FileDelete ( @DesktopDir & "\AutoIt 反編譯工具.lnk" )
- FileDelete ( @DesktopDir & "\AutoIt 代碼簡易格式化工具.lnk" )
- FileDelete ( @DesktopDir & "\Reg2Au3(UniCode).lnk" )
- FileDelete ( @DesktopDir & "\Au3Info.lnk" )
- FileDelete ( @DesktopDir & "\SciTE.lnk" )
- FileDelete ( @DesktopDir & "\Aut2exe.lnk" )
- FileDelete ( @DesktopDir & "\KODA FormDesigner .lnk" )
- ;;移除登錄檔
- RegDelete ( "HKEY_CLASSES_ROOT\.au3" )
- RegDelete ( "HKEY_CLASSES_ROOT\.a3x" )
- RegDelete ( "HKEY_CLASSES_ROOT\AutoIt3Script" )
- RegDelete ( "HKEY_CLASSES_ROOT\AutoIt3XScript" )
- RegDelete ( "HKEY_CLASSES_ROOT\AutoItX3.Control" )
- RegDelete ( "HKEY_CLASSES_ROOT\AutoItX3.Control.1" )
- ;;讓REG即時生效
- ProcessClose ( "explorer.exe" )
- Sleep ( 2000 )
- If ProcessExists ( "explorer.exe" ) Then
- MsgBox (0 , "移除成功" , "AutoIt 移除已完成" & @CRLF & "" & @CRLF & "已將設定檔和UDF備份至:" & @CRLF & $BakFolder )
- Else
- Run ( "explorer.exe" )
- MsgBox (0 , "移除成功" , "AutoIt 移除已完成" & @CRLF & "" & @CRLF & "已將設定檔和UDF備份至:" & @CRLF & $BakFolder )
- EndIf
- ;;移除AutoIt檔案
- ;;防止誤刪
- if Not @compiled Then
- Msgbox(48,"Kill Me","請編譯後執行...")
- Exit
- Endif
- ;;防止被設置 系統 和 隱藏 只讀 等屬性
- if FileGetAttrib ( $AURUT )<>"A" Then
- FileSetAttrib ( $AURUT , "-RSH" , 0 )
- Endif
- ;;移除AU3安裝目錄
- Exit Run ( @ComSpec & ' /c ping 127.0.0.1 -n 3&rd /s/q "' & $AURUT & '"&exit' , @SystemDir , @SW_HIDE )
複製代碼 |
|