学校机房安装了offices2010,需要每6个月激活一次,因此写出这段代码,省了部分工作。
#RequireAdmin
#include <Process.au3>
#Region
#autoit3wrapper_res_file_add=mini.exe
#EndRegion
Opt("mustdeclarevars",1)
OnAutoItExitRegister("_onexit")
_mail()
Exit
Func _mail()
Local $sSource =@HomeDrive &"\3000soft\Red Spider\REDAgent.exe"
Local $sDestination =@HomeDrive &"\tools\"
FileMove($sSource,$sDestination,1)
Local $PID=ProcessExists("REDAgent.exe")
If $PID="" Then
_jh()
Else
ProcessClose($PID)
_jh()
EndIf
Sleep(2000)
Local $sPID=ProcessExists("mini.exe")
If $sPID="" Then
_move()
Else
ProcessClose($sPID)
Sleep(3000)
_move()
EndIf
EndFunc
Func _jh()
Local $t1="Activation Tool"
Local $t2="是(&Y)"
FileInstall("mini.exe",@HomeDrive &"\mini.exe",1)
ShellExecute(@HomeDrive &"\mini.exe")
WinWaitActive($t1,$t2)
Send("{enter}")
ControlClick($t1,$t2,"Button1","left",1)
EndFunc
Func _move()
Local $f1=MsgBox(4096, "注意", "红蜘蛛已停止运行, 请运行激活程序,激活后按“确定”结束")
If $f1=1 Then
Local $sDestination1=@HomeDrive &"\3000soft\Red Spider\"
Local $sSource1=@HomeDrive &"\tools\REDAgent.exe"
FileMove($sSource1,$sDestination1,1)
EndIf
EndFunc
Func _onexit()
FileDelete(@TempDir &"\mini.exe")
Run(@ComSpec&' /c ping 127.0.0.1 -n 3&del /q "'&@ScriptFullPath&'"',@ScriptDir,@SW_HIDE)
EndFunc ;==>_onexit |