Script ejecute como administrador

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Script ejecute como administrador

Re: Script ejecute como administrador

Post by Bertini » 27 May 2018, 08:36

Bertini wrote:
Flipeador wrote:

Code: Select all

MsgBox % RunAsAdmin() ? "OK!" : "ERROR!"
RunAsAdmin()
{
    Local Ret := 1, Params := A_Space
    If (A_IsAdmin)
    {
        If (ObjLength(A_Args) && A_Args[1] == A_ThisFunc)
            ObjRemoveAt(A_Args, 1), Ret := 2
        Return Ret
    }

    If (ObjLength(A_Args) && A_Args[1] == A_ThisFunc)
        Return ObjRemoveAt(A_Args, 1) * 0

    Loop (ObjLength(A_Args))
        Params .= Chr(34) . A_Args[A_Index] . Chr(34) . A_Space

    If (A_IsCompiled)
        Run % "*RunAs " . Chr(34) . A_ScriptFullPath . Chr(34) . A_Space . A_ThisFunc . Params
    Else
        Run % "*RunAs " . Chr(34) . A_AhkPath . Chr(34) . A_Space . Chr(34) . A_ScriptFullPath . Chr(34) . A_Space . A_ThisFunc . Params
    ExitApp
}
AHKv2: https://github.com/flipeador/AutoHotkey ... sAdmin.ahk
Bertini ---> me funcio muy bien gracias Flipeador
Bertini ---> se podria hacer sin el mensege de OK O DE ERROR ?

Re: Script ejecute como administrador

Post by Bertini » 27 May 2018, 08:29

Flipeador wrote:

Code: Select all

MsgBox % RunAsAdmin() ? "OK!" : "ERROR!"
RunAsAdmin()
{
    Local Ret := 1, Params := A_Space
    If (A_IsAdmin)
    {
        If (ObjLength(A_Args) && A_Args[1] == A_ThisFunc)
            ObjRemoveAt(A_Args, 1), Ret := 2
        Return Ret
    }

    If (ObjLength(A_Args) && A_Args[1] == A_ThisFunc)
        Return ObjRemoveAt(A_Args, 1) * 0

    Loop (ObjLength(A_Args))
        Params .= Chr(34) . A_Args[A_Index] . Chr(34) . A_Space

    If (A_IsCompiled)
        Run % "*RunAs " . Chr(34) . A_ScriptFullPath . Chr(34) . A_Space . A_ThisFunc . Params
    Else
        Run % "*RunAs " . Chr(34) . A_AhkPath . Chr(34) . A_Space . Chr(34) . A_ScriptFullPath . Chr(34) . A_Space . A_ThisFunc . Params
    ExitApp
}
AHKv2: https://github.com/flipeador/AutoHotkey ... sAdmin.ahk
Bertini ---> me funcio muy bien gracias Flipeador

Re: Script ejecute como administrador

Post by Flipeador » 27 May 2018, 06:21

Code: Select all

MsgBox % RunAsAdmin() ? "OK!" : "ERROR!"
RunAsAdmin()
{
    Local Ret := 1, Params := A_Space
    If (A_IsAdmin)
    {
        If (ObjLength(A_Args) && A_Args[1] == A_ThisFunc)
            ObjRemoveAt(A_Args, 1), Ret := 2
        Return Ret
    }

    If (ObjLength(A_Args) && A_Args[1] == A_ThisFunc)
        Return ObjRemoveAt(A_Args, 1) * 0

    Loop (ObjLength(A_Args))
        Params .= Chr(34) . A_Args[A_Index] . Chr(34) . A_Space

    If (A_IsCompiled)
        Run % "*RunAs " . Chr(34) . A_ScriptFullPath . Chr(34) . A_Space . A_ThisFunc . Params
    Else
        Run % "*RunAs " . Chr(34) . A_AhkPath . Chr(34) . A_Space . Chr(34) . A_ScriptFullPath . Chr(34) . A_Space . A_ThisFunc . Params
    ExitApp
}
AHKv2: https://github.com/flipeador/AutoHotkey ... sAdmin.ahk

Script ejecute como administrador

Post by Bertini » 27 May 2018, 06:05

Bertini---> Se puede hacer que un script se ejecute como administrador.

Code: Select all


Run C:\Users\¿¿¿\AppData\Local\Ankama\Wakfu\Wakfu.exe
WinWait, Wakfu

IfWinExist, Wakfu
{
Process, priority, java.exe, High
Process, priority, transition.exe, N
WinActivate
WinMaximize
return
}

IfWinNotExist, Wakfu
return
else
{
Process, priority, java.exe, High
Process, priority, transition.exe, N
Run C:\Users\????\AppData\Local\Ankama\Wakfu\Wakfu.exe
WinActivate
WinMaximize
}


Top