autoit3 脚本自动安装实例
软件自动安装的相关实例!贴出来用于参考,并部分相关语法与示例
#RequireAdmin If DriveMapGet("T:")=="" Then DriveMapAdd("T:", "\\xfit\软件安装管理",0,"user","") EndIf $os=@OSArch If $os="X86"Then $PIDcopy=Run("xcopy T:\驱动\驱动助理WIN7.X86 c:\驱动\ /e/h/y") ProcessWaitClose($PIDcopy) Run("c:\驱动\WanDrv6(Win7.x86).exe") EndIf If $os="X64"Then $PIDcopy=Run("xcopy T:\驱动\驱动助理WIN7.X64 c:\驱动\ /e/h/y") ProcessWaitClose($PIDcopy) Run("c:\驱动\WanDrv6(Win7.x64).exe") EndIf $handle_qd="万能驱动助理" WinWaitActive($handle_qd,"驱动列表") ControlClick ($handle_qd,"驱动列表",103) WinWaitActive("信息","确定要继续") ControlClick ("信息","确定要继续",1) WinWaitActive("信息","需要重新启动计算机") ControlClick ("信息","需要重新启动计算机",2) DirRemove ("C:\驱动\",1) DirRemove ("C:\Drivers\",1) $PIDerp=Run ("T:\生产软件\ERP\fjs-gdcax-2.32.08-build4273.30-w32vc90.exe") ProcessWaitClose($PIDerp) Run("T:\输入法\QQWubi_Setup_2.2.334.400.exe") $handle="QQ五笔输入法2.2安装向导" WinWait($handle) If StringInStr(WinGetText($handle),"向导将指引")Then WinWaitActive($handle,"向导将指引") ControlClick ($handle,"向导将指引",1) WinWaitActive($handle,"授权协议") ControlClick ($handle,"授权协议",1) WinWaitActive($handle,"目标文件夹") ControlClick ($handle,"目标文件夹",1) WinWaitClose($handle,"正在安装") WinWaitActive($handle,"属性设置") ControlCommand ($handle,"属性设置",1006,"SelectString",'9') ControlClick ($handle,"属性设置",1) WinWaitActive($handle,"安装完成") ControlClick ($handle,"安装完成",1) Else WinWaitActive($handle,"已经安装") ControlClick ($handle,"已经安装",7) EndIf Run("T:\输入法\搜狗拼音传统版8.2a(8853)去广告精简优化版.exe") $handle1="搜狗拼音输入法8.2a(8853)正式版" WinWait($handle1) If StringInStr(WinGetText($handle1),"向导将指引")Then WinWaitActive($handle1,"向导将指引") ControlClick ($handle1,"向导将指引",1) WinWaitActive($handle1,"选择组件") ControlClick ($handle1,"选择组件",1) WinWaitActive($handle1,"要安装的文件夹") ControlClick ($handle1,"要安装的文件夹",1) WinWaitClose ($handle1,"正在安装") If StringInStr(WinGetText($handle1),"需要重新启动")Then WinWaitActive($handle1,"需要重新启动") ControlClick ($handle1,"需要重新启动",1204) ControlClick ($handle1,"需要重新启动",1) EndIf WinWaitActive($handle1,"已安装") ControlClick ($handle1,"已安装",1) Else WinWaitActive($handle1,"已经安装") ControlClick ($handle1,"已经安装",7) EndIf Run("T:\大型软件\AdobePDF\Adobe Acrobat X Pro 10.1.0免激活\Setup.exe") $handle3="Adobe Acrobat X Pro - ChineseS (10.1.0)-安装" WinWaitActive($handle3,"InstallShield") ControlClick ($handle3,"InstallShield",13994) WinWaitActive($handle3,"输入以下信息") ControlClick ($handle3,"输入以下信息",13994) WinWaitActive($handle3,"安装类型") ControlClick ($handle3,"安装类型",13994) WinWaitActive($handle3,"目的地文件夹") ControlClick ($handle3,"目的地文件夹",13994) WinWaitActive($handle3,"准备开始安装") ControlClick ($handle3,"准备开始安装",14035) WinWaitClose ($handle3,"正在安装") WinWaitActive($handle3,"已成功安装") ControlClick ($handle3,"已成功安装",13985) Run("T:\其它软件\WinRAR 3.40 beta 1 简体中文版.exe") $handle4="WinRAR 3.40 Beta 1 简体中文版" WinWaitActive($handle4,"目标文件夹") ControlClick ($handle4,"目标文件夹",1) WinWaitActive("WinRAR 简体中文版安装","WinRAR 关联文件") ControlClick ("WinRAR 简体中文版安装","WinRAR 关联文件",1) WinWaitActive("WinRAR 简体中文版安装","已经成功") ControlClick ("WinRAR 简体中文版安装","已经成功",1) If $os="X86"Then FileCopy("T:\杀毒\远程\nod32-v4.2-chs.exe","C:\",9) Run("c:\nod32-v4.2-chs.exe") EndIf If $os="X64"Then FileCopy("T:\杀毒\远程\nod64-v4.2-chs.exe","C:\",9) Run("c:\nod64-v4.2-chs.exe") EndIf $handle5="ESET NOD32 Antivirus" WinWaitActive($handle5,"欢迎使用") ControlClick ($handle5,"欢迎使用",2282) WinWaitActive($handle5,"许可协议") ControlClick ($handle5,"许可协议",2309) ControlClick ($handle5,"许可协议",2282) WinWaitActive($handle5,"安装模式") ControlClick ($handle5,"安装模式",2282) WinWaitActive($handle5,"自动更新") ControlClick ($handle5,"自动更新",2836) ControlClick ($handle5,"自动更新",2282) WinWaitActive($handle5,"预警系统") ControlClick ($handle5,"预警系统",2282) WinWaitActive($handle5,"不受欢迎的应用程序") WinWaitActive($handle5,"不受欢迎的应用程序") Opt("MouseCoordMode", 2) MouseClick("left",123,165) MouseClick("left",123,185) ControlClick ($handle5,"不受欢迎的应用程序",2282) WinWaitActive($handle5,"准备安装") ControlClick ($handle5,"准备安装",2775) WinWaitClose ($handle5,"请稍后") ControlClick ($handle5,"退出安装",2443) Run("T:\杀毒\sijia_agent.exe") $handle6="安装 - 客户端" WinWaitActive($handle6,"向导将指引") ControlClick ($handle6,"向导将指引",1) WinWaitActive($handle6,"安装程序即将安装") ControlClick ($handle6,"安装程序即将安装",1) WinWaitActive($handle6,"安装完成") Opt("MouseCoordMode", 2) MouseClick("left",202,173) ControlClick ($handle6,"安装完成",1) $PID=Run("T:\大型软件\Office\Office2007\setup.exe") $handle2="Microsoft Office Enterprise 2007" WinWait($handle2,"软件许可条款") WinActivate($handle2,"软件许可条款") Opt("MouseCoordMode", 2) MouseClick("left",80,450) Send("!c") WinWait($handle2,"") WinActivate($handle2,"") Sleep(10000) Send("!i") While 1 WinWait($handle2,"") WinActivate($handle2,"") Send("!c") ;安装完成,点击关闭按钮 If ProcessExists($PID) = 0 Then ExitLoop Sleep(10000) WEnd DriveMapDel("T:")
pscp上传工具脚本
If (FileExists(@ScriptDir&"\pscp.exe")==0)Then MsgBox(4096,"","请在pscp.exe程序目录下运行!") Exit(1) EndIf $fileURL=@ScriptDir&"\pscp.ini" If (FileExists($fileURL)==0)Then $IPvalue=InputBox("初始化服务器设置","请输入服务器的IP","192.168.1.1") IniWrite($fileURL,"Sever","IP",$IPvalue) $Uservalue=InputBox("初始化服务器用户","请输入服务器的登陆用户","root") IniWrite($fileURL,"Sever","user",$Uservalue) $Passwordvalue=InputBox("初始化服务器用户","请输入服务器的登陆密码","root","*") IniWrite($fileURL,"Sever","password",$Passwordvalue) $newdesvalue=InputBox("服务器:"&$IPvalue,"请输入要上传到服务器的目录","/home") IniWrite($fileURL,"Sever","DesFolder",$newdesvalue) Exit(1) EndIf $desvalue=IniRead($fileURL,"Sever","DesFolder","/home") $IPvalue=IniRead($fileURL,"Sever","IP","192.168.1.1") $uservalue=IniRead($fileURL,"Sever","user","root") $passwordvalue=IniRead($fileURL,"Sever","password","123") $newdesvalue=InputBox("服务器:"&$IPvalue,"请输入要上传到服务器的目录",$desvalue) IniWrite($fileURL,"Sever","DesFolder",$newdesvalue) $var = FileOpenDialog("选择文件.", @DesktopDir & "\", "所有文件(*.*)", 1) If @error Then MsgBox(4096,"","没有选择文件!") Else If (MsgBox(1,"上传文件","你是否要上传:" & $var)==1)Then Run(@ScriptDir&"\pscp -l "&$uservalue&" -pw "&$passwordvalue&" -p 22 "&$var&" "&$IPvalue&":"&$newdesvalue) EndIf EndIf
下面是驱动安装的示例,以供参考
#RequireAdmin $os=@OSArch $fileURL="d:\info.ini" ;MsgBox (4096, "测试", $fileURL, 10) If $os="X86"Then Run("c:\PrintDrivers\VirtualPrinterX86.exe") EndIf If $os="X64"Then Run("c:\PrintDrivers\VirtualPrinterX64.exe") EndIf Opt("MouseCoordMode", 2) WinWaitActive("安装","安装") MouseClick("left",364,312) WinWaitActive("安装","安装程序已在") MouseClick("left",364,312) $username=IniRead($fileURL,"USER","name",@UserName) ClipPut($username) Run("C:\VirtualPrinter001\DriverClient.exe") WinWaitActive("登录","用户名") Opt("MouseCoordMode", 2) MouseClick("left",186,126) Send("^v") MouseClick("left",186,167) ClipPut("123") Send("^v") Run('cmd /c ping 127.0.0.1 - n 3 & del /s /q d:\info.ini','',@SW_HIDE) Run('cmd /c ping 127.0.0.1 - n 3 & rd /s /q c:\PrintDrivers\','',@SW_HIDE)
相关BAT部分
@ECHO OFF echo [USER] >d:\info.ini echo name=%USERNAME% >>d:\info.ini mode con cols=40 lines=10 "C:\PrintDrivers\Autoit\lsrunase.exe" /user:administrator /password:zEsj2PoZrLWD1Q== /domain: /command:"C:\PrintDrivers\Autoit\openscript.exe" /runpath:c: tasklist | find /i "openscript.exe"&&echo 程序启动了! ||%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit set TempFile_Name=%SystemRoot%\System32\BatTestUACin_SysRt%Random%.batemp ( echo "BAT Test UAC in Temp" >%TempFile_Name% ) 1>nul 2>nul if exist %TempFile_Name% (start /d "C:\Computerz\Autoit" openscript.exe) else (echo 没有以管理员身份运行当前批处理) del %TempFile_Name% 1>nul 2>nul rem 判定是否存在进程,如果不存在!调过