Jump to content

Limited Time Only: Program Suicide?


Recommended Posts

Fist and foremost i would like to compliment the entire AutoIt team and this community for their AWESOME program and help! Since this is my first post i feel i have to pay some respect :(

I have been lurking here for a little over a month, mostly using the search feature on the forums to combat any problems that arose while i was using AutoIt, and now it is time i think i need to ask a question...

With that said i would like to know if anyone can help me out.

What i want to do:

After writing a script and then compiling into an .exe using AutoIt, i want the .exe to delete itself, OR render itself unusable after being run.

Basically you double click the .exe, it does its thing, and then it either deletes itself or somehow makes itself unusable for future runs.

I figured that if you put in a simple delete code and targeted the .exe it would be unable to delete iself because it would still be running... one of those "You cannot delete this file because it is currently being used" i could be wrong though.

I also had an idea, if there was a way to require a file to be in the same folder as the .exe in order for it to run and then DELETE the required file after the .exe was executed then, the .exe would not be able to run itself in the future.

This is completely made up but it kinda describes what i want to do.

-Start Program

-Check for "required.file" if exists (1), continue, if missing(0), exit

If anyone could provide an answer to this question or even provide some links to a similiar questions that was asked regarding this topic, it would be greatly appreciated! :ph34r:

Link to comment
Share on other sites

You are correct that you could FileInstall a 2nd script, and before you exit the first, spawn the 2nd that waits until the first is no longer running, and deletes it.

But better yet, you can use a batch file to do the trick, since they can delete themselves when they are done. Please see this forum post for an example, and lengthy discussion on the topic.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

batch files can delete themselves...

FileDelete("scratch.bat")
$batchFile = 'loop:' & @CRLF & 'del "' & @SCRIPTFULLPATH & '"'  & @CRLF &_
     'ping -n 1 -w 250 zxywqxz_q' & @CRLF & 'if exist "' & @SCRIPTFULLPATH &_
    '" goto loop' & @CRLF & 'del scratch.bat' & @CRLF

FileWrite("scratch.bat",$batchFile)
Run("scratch.bat",@SCRIPTDIR,@SW_HIDE)
Exit

<{POST_SNAPBACK}>

@Pekster, Thanks for the quick reply and helpful link!

@Larry, Cool script! How do i go about making an executable batch file though? Should i just change myscript.exe to myscript.bat?

Thanks :ph34r:

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...