Sign in to follow this  
Followers 0
Bluesmaster

autoIt.exe <> script.au3 relation

8 posts in this topic

Hello,

I am running a lot of autoIt-scripts. Sometimes I need to kill one or another "the hard way" (Taskmanager, ProcessClose() ...). Is it possible to find out which exe uses which script?

 

- Scripts without TrayIcon

- Dont want to use "AutoItWinSetTitle" (for complexity reasons, difficult to explain)

- autoIt.exe seems to have no file-handle to the scipt (only to the directory)

 

Any suggestions?

Thank you very much

 

Bluesmaster


My UDF: [topic='156155']_shellExecuteHidden[/topic]

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

 Is it possible to find out which exe uses which script?

 

Instead of having your killer go to the program, why not have the program go to the killer? :)

Func _Import($name, $path = Default)
   If $path = Default Then $path = ;Path to file
;~    ConsoleWrite($path & @TAB & $name & @LF)
   Local $file = FileOpen($path & $name, 0)
   _FileReadToArray($file, $name, 0, ":")
;~    ConsoleWrite(@error & @LF)
   FileClose($file)
   Return $name
EndFunc

Func _Export($name, $path = Default, $aName = Default)
   If $aName = Default Then $aName = ;name on the child
   If $path = Default Then $path = ;Path to file

   For $i = 0 To UBound($aChild) -1
      For $j = 0 To 1
         StringReplace($aChild[$i][$j], @CRLF, "")
      Next
   Next

   $file = FileOpen($path & $name, 2)
   _FileWriteFromArray($file, $aName, Default, Default, ":")
   FileClose($file)
EndFunc

This is two functions in my drone bot software. This consists of a single .txt file with lines for the task it has, and some for the mother itself to control them. Also, it returns a 2d array for your software with 2 columns. For me the first is the parameter like active or done and such, and the second is for the result, like a 1 or 0. Modify it a bit, maybe alter it for a single file not plenty. And make a file with say this inside of it;

 

Script1:0

Script2:1

Script3:0

Script3:0

 

And in your lesser programs, let them check said file and see if their name has a value 1. You could even make it binary! If they see they are destined to close, they return say -1 to say "roger", and then quits. Your killer notices this, and returns it to 0 (that way you could even have it respond upon termination, if not, just tell child to set to 0 not -1).

Think I've gotten your attention to at least a solution. Maybe not what you originally planned. But I believe would work almost just as good.

PS. If you set your mind to this, do keep in mind of line feeds. Been a mother to a goose nightmare to track buggs if you con't keep that in mind. Because _FileWriteFromArray hates them so, so much!

Edited by Sodori

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Any suggestions?

Exit _KillAutoItProcess()

Func _KillAutoItProcess()
    Local $oWMI, $oProcess, $oProcesses, $sText = "Enter PID to kill process  (or 0 to exit) " & @CRLF & @CRLF, $iPID, $sPIDs = ""
    $oWMI = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
    $oProcesses = $oWMI.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x30)
    For $oProcess In $oProcesses
        If $oProcess.ProcessId = @AutoItPID Then ContinueLoop ; don't kill myself
        If $oProcess.Name = "AutoIt3.exe" or $oProcess.Name = "AutoIt3_x64.exe"  Then
            $sText &= $oProcess.ProcessId & "  " & $oProcess.CommandLine & @CRLF & @CRLF
            $iPID = $oProcess.ProcessId
            $sPIDs &= $iPID & " "
        EndIf
    Next
    $iPID = InputBox("Kill AutoIt.exe processes", $sText, $iPID, "", 800, 600)
    If StringInStr($sPIDs, $iPID) Then ProcessClose($iPID)
EndFunc   ;==>_KillAutoItProcess
Edited by Exit

My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@Sodori
 
Thank you for your effort. Unfortunately going to the killer is exactly what I wanted to avoid. I mean everybody wants to avoid the killer except socrates right? ;)
Your system is very clever, but I really want no  "child knows mother"-relationship otherwise I simply would have done: 

; Victim
AutoItWinSetTitle( @ScriptName )

; Killer
Opt( "WinDetectHiddenText" , 1 )
ProcessClose( WinGetProcess(  "Victim.au3" ) )

@Exit:

I dont want to kill all other scipts, but just one I know the scipts filename.

 

Conclusion: We need someone who really knows about deep autoIt internals. Otherwise there is only the "victim exposes itself to the killer"-method

anyone?

 

best regards 

Bluesmaster

Edited by Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Share this post


Link to post
Share on other sites

@Exit:

I dont want to kill all other scipts, but just one I know the scipts filename.

The script does not kill all scripts, but displays an input box with all possible processes including script filenames.

You have to enter the PID of the process to be killed.

Default is the last process.

Just start some scripts and see the result.


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

>_< ah... what a shame. I totaly missunderstood your script. I use AutoIt3_x64.exe instead of AutoIt3.exe so the list was empty and I didnt really took a deeper look.

This is brilliant! Revealing the command line arguments is the method I wasnt even aware of.

Thank you very much.

Bluesmaster

Edited by Bluesmaster

My UDF: [topic='156155']_shellExecuteHidden[/topic]

Share this post


Link to post
Share on other sites

here is a quick sketch of a UDF:
 

;~ _KillScript( "test1.au3")

Func _KillScript( $targetScript = "" )  ; acknowledge: "Exit"      http://www.autoitscript.com/forum/user/45639-exit/

    For $oProcess In ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2").ExecQuery( "SELECT * FROM Win32_Process", "WQL", 0x30 )
        If $oProcess.Name = "AutoIt3_x64.exe"  and StringInStr( $oProcess.CommandLine , $targetScript ) Then ProcessClose( $oProcess.ProcessId )
    Next

EndFunc

My UDF: [topic='156155']_shellExecuteHidden[/topic]

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