Sign in to follow this  
Followers 0
BeeranStream

Execution owner query ?

6 posts in this topic

Hi , first of all .. a great thanks to the AutiIT guys , excellent software.

Now .. does anybody know if is possible to capture the origininating executable if i'm for example calling my "autit.exe" from another executable or script like batch/kix .. i would like to restrict inside the "autoit.exe" file "who"/"what" can execute my precious compiled autoit files ;)

Thanks for any assistance , been scratching my head alot on this one .. hehe

/B

Share this post


Link to post
Share on other sites



I think you'll have to use Group Policies/Permissions to accomplish this....


[u]Do more with pre-existing apps![/u]ANYGUIv2.8

Share this post


Link to post
Share on other sites

I think you'll have to use Group Policies/Permissions to accomplish this....

hm, policies wont be that good for me

.. i was wondering if i could set some in-paramater that tells me if the autoit.exe was started by "login.bat" or some other exec.

I dont want to limit the exectuion on a policy level since everyone needs to execute this exe file , just that it needs to be executed from a certain logon script.

Share this post


Link to post
Share on other sites

Not the prettiest piece of code but it'll do the job for you. Can be modified easily enough to return the parent's PID if preferred. Requires PsList to work (free; can be included within your script using FileInstall()).

MsgBox(0x40, 'GetParentProcessName()', GetParentProcessName())

Func GetParentProcessName()

; @Error = 1 -> Could not run PSList
; @Error = 2 -> Could not find script PID in output
; @Error = 3 -> Could not determine the parent

; Get the necessary information from PSList
    Local $PrevOpt = Opt('RunErrorsFatal', 0)
    Local $PSList = Run('PSList -T', '', '', 2)
    Local $Error = @Error
    Opt('RunErrorsFatal', $PrevOpt)
    If ($Error) Then
        SetError(1)
        Return ''
    EndIf
    Local $PInfo = ''
    Do
        $PInfo &= StdOutRead($PSList, 4096)
    Until @Error

; Convert the data into an array for easy line-by-line access
    $Pinfo = StringSplit($PInfo, @CRLF, 1)

; Determine line number of corresponding entry
    Local $Line, $Success = False
    For $Line = 1 To $PInfo[0]
        If StringRegExp($PInfo[$Line], '.*?' & @AutoItPID & '(?:\s+\d+){6}\>') Then
            $Success = True
            ExitLoop
        EndIf
    Next
    If Not($Success) Then
        SetError(2)
        Return ''
    EndIf

; Determine indentation amount of this information
    Local $Indent = StringLen($PInfo[$Line]) - StringLen(StringStripWS($PInfo[$Line], 1))

; Find the first previous line with a lower indentation
; This line will hold information on the parent
    While $Line > 0
        $Line -= 1
        Local $Temp = StringLen($PInfo[$Line]) - StringLen(StringStripWS($PInfo[$Line], 1))
        If $Temp < $Indent Then
            Local $Ret = StringRegExp($PInfo[$Line], '\s*(.*)(?:\s+\d+){7}\>', 1)
            Return $Ret[0]
        EndIf
    WEnd

    SetError(3)
    Return ''

EndFunc

Share this post


Link to post
Share on other sites

Just have your batch file set an environment variable at its beginning, run your AutoIt script which tests for the existence of the environment variable before taking any action, then unset the environment variable at the end of the batch file. You don't have to care if the user can run the script, you can just make it so it doesn't do anything outside your sanctioned duty for it.

Environment variables are sufficiently arcane these days that most users don't know they exist, so I think it would be a decent way to foil undesired use of your compiled script.


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0