Global $soft_name = "SketchUp 2017"
Global $soft_path = "安装文件所在路径"
Global $domain = "域"
Global $admin = "用户名"
Global $passwd = "密码"
;检查是否安装
If RegRead("hklm64\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{36CD1188-EAD6-4AA9-B9C8-94BE4852D67B}", "UninstallString") = 'MsiExec.exe /X{36CD1188-EAD6-4AA9-B9C8-94BE4852D67B}' Then
If MsgBox(4,"提示",$soft_name & " 已安装,是否卸载") = 6 Then
uninstall_su2017()
Else
Exit
EndIf
Else
setup_su2017()
EndIf
Func uninstall_su2017()
;检查进程是否存在
If ProcessExists("SketchUp.exe") Then ProcessClose("SketchUp.exe")
If ProcessExists("Style Builder.exe") Then ProcessClose("Style Builder.exe")
If ProcessExists("LayOut.exe") Then ProcessClose("LayOut.exe")
;卸载
MsgBox(0,'提示','开始卸载 ' & $soft_name,3)
Run("msiexec /x {36CD1188-EAD6-4AA9-B9C8-94BE4852D67B}")
WinWait("Windows Installer")
WinActivate("Windows Installer")
Send("!y")
WinWait("SketchUp Pro 2017 (64-bit)")
WinWaitClose("SketchUp Pro 2017 (64-bit)")
If MsgBox(4,"提示",$soft_name & " 已卸载,是否重新安装") =6 Then
setup_su2017()
Else
Exit
EndIf
EndFunc
Func setup_su2017()
;安装
MsgBox(0,"提示","开始自动安装,请不要操作电脑",3)
RunAs($admin, $domain, $passwd, 2, $soft_path & "\SketchUpPro2017-zh-CN-x64.exe", $soft_path)
Opt("WinTitleMatchMode", 2)
WinWait("Extracting Installer")
WinWaitClose("Extracting Installer")
If WinWait("SketchUp Pro 2017-64-bit (中文-简体中文) 安装程序","","3") Then
WinActivate("SketchUp Pro 2017-64-bit (中文-简体中文) 安装程序")
Send("!i")
EndIf
WinWait("SketchUp Pro 2017 (64-bit) 安装","欢迎使用")
WinActivate("SketchUp Pro 2017 (64-bit) 安装","欢迎使用")
Send("!n")
WinWait("SketchUp Pro 2017 (64-bit) 安装","目标文件夹")
WinActivate("SketchUp Pro 2017 (64-bit) 安装","目标文件夹")
Send("!n")
WinWait("SketchUp Pro 2017 (64-bit) 安装","准备安装")
WinActivate("SketchUp Pro 2017 (64-bit) 安装","准备安装")
Send("!i")
WinWait("SketchUp Pro 2017 (64-bit) 安装","已完成")
WinActivate("SketchUp Pro 2017 (64-bit) 安装","已完成")
Send("!f")
;激活
FileCopy($soft_path & "\替换文件\SketchUp.exe","C:\Program Files\SketchUp\SketchUp 2017",1)
FileCopy($soft_path & "\替换文件\LayOut\LayOut.exe", "C:\Program Files\SketchUp\SketchUp 2017\LayOut",1)
FileCopy($soft_path & "\替换文件\Style Builder\Style Builder.exe", "C:\Program Files\SketchUp\SketchUp 2017\Style Builder",1)
MsgBox(0,"提示",$soft_name & " 安装完成",3)
EndFunc