Local $UserName = "red" ;管理员名称
Local $PassWord = "redapple" ;管理员密码
Send("#r")
WinWaitActive("[CLASS:#32770]")
Local $sdoscommand = "runas /user:" & $UserName & " " & "cmd.exe"
Local $flag = ControlSend("", "", "[CLASS:Edit; INSTANCE:1]", $sdoscommand & "{Enter}")
Sleep(300)
WinWaitActive("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
Sleep(300)
ControlSend("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]", "", "", $PassWord & "{Enter}")
Sleep(300)
WinClose("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
Sleep(2000)
If WinExists("[CLASS:ConsoleWindowClass]") Or WinExists("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]") Then
If WinExists("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]") Then
WinWaitActive("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
ControlSend("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]", "", "", "D:\soft\微软常用运行库合集2023.02.02.exe" & "{Enter}")
WinWaitNotActive("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
WinClose("[CLASS:CASCADIA_HOSTING_WINDOW_CLASS]")
EndIf
If WinExists("[CLASS:ConsoleWindowClass]") Then
WinWaitActive("[CLASS:ConsoleWindowClass]")
ControlSend("[CLASS:ConsoleWindowClass]", "", "", "D:\soft\微软常用运行库合集2023.02.02.exe" & "{Enter}")
WinWaitNotActive("[CLASS:ConsoleWindowClass]")
WinClose("[CLASS:ConsoleWindowClass]")
EndIf
EndIf
本机测试正常。 |