Jump to content

Exe Suicide


Recommended Posts

Yes use this:

Opt("OnExitFunc", "_SelfDelete")

... your code ...

Func _SelfDelete()
    Local $cmdfile
    FileDelete(@TempDir & "\dcp.cmd")
    $cmdfile = ':loop' & @CRLF _
    & 'del "' & @ScriptFullPath & '"' & @CRLF _
    & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
    & 'del ' & @TempDir & '\dcp.cmd'
    FileWrite(@TempDir & "\dcp.cmd", $cmdfile)
    Run(@TempDir & "\dcp.cmd", @TempDir, @SW_HIDE)
EndFunc
Link to comment
Share on other sites

compile it and with Start>>Run>>iExpress.exe and put a batch file in the package which tells te file to delete itself :)

Some Projects:[list][*]ZIP UDF using no external files[*]iPod Music Transfer [*]iTunes UDF - fully integrate iTunes with au3[*]iTunes info (taskbar player hover)[*]Instant Run - run scripts without saving them before :)[*]Get Tube - YouTube Downloader[*]Lyric Finder 2 - Find Lyrics to any of your song[*]DeskBox - A Desktop Extension Tool[/list]indifference will ruin the world, but in the end... WHO CARES :P---------------http://torels.altervista.org

Link to comment
Share on other sites

Is there a way that I can remove the executable once it's been closed at the end of the program? Basically delete itself so it leaves no trace?

you can use a batch script that is executed on autoitexit.

Func OnAutoItExit ( )

...

EndFunc

In the beginning there was nothing and then even that exploded - anonymous

Link to comment
Share on other sites

Yes use this:

Opt("OnExitFunc", "_SelfDelete")

... your code ...

Func _SelfDelete()
    Local $cmdfile
    FileDelete(@TempDir & "\dcp.cmd")
    $cmdfile = ':loop' & @CRLF _
    & 'del "' & @ScriptFullPath & '"' & @CRLF _
    & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
    & 'del ' & @TempDir & '\dcp.cmd'
    FileWrite(@TempDir & "\dcp.cmd", $cmdfile)
    Run(@TempDir & "\dcp.cmd", @TempDir, @SW_HIDE)
EndFunc
What an awesome piece of code, this is the best.
Link to comment
Share on other sites

  • Moderators

What an awesome piece of code, this is the best.

Open SciTe, type in SelfDelete<space> :)

does this olso works when you do alt+ctrl+delete and kill the process????

What did your test reveal?

In all seriousness, you've stopped the executable outside of itself, which means it did not have a chance to do any exit functions.

Now for my question, why would you want this to happen?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Open SciTe, type in SelfDelete<space> :)

What did your test reveal?

In all seriousness, you've stopped the executable outside of itself, which means it did not have a chance to do any exit functions.

Now for my question, why would you want this to happen?

i'm making software that 2 .exe needs eatchotehr if 1 is not running then he sent a signal tot the server and stops himself i want something that when u kill the .exe he needs to sent the signal now i'm useing 2 .exe for it that both are running..

Link to comment
Share on other sites

  • Moderators

i'm making software that 2 .exe needs eatchotehr if 1 is not running then he sent a signal tot the server and stops himself i want something that when u kill the .exe he needs to sent the signal now i'm useing 2 .exe for it that both are running..

If executables could still process code after being terminated by an outside process, there wouldn't be any need for the outside process really.

You'll need to run two executables, one to run the code, the 2nd to monitor the one that is running the code.

If the 2nd executable sees that the first one is no longer in the process list, and it sees that the first one still exists on the hard drive, then it knows it has been terminated outside of itself.

Since you are already using two executables, then it should be trivial to implement them making sure they both exist before carrying out an action that could result in catastrophic failure.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...