Jump to content

How can I delete a .exe....


Recommended Posts

  • Developers

I made a program, which I want to delete using autoit, but I cant get it to delete itself, I've tried this...

FileDelete(@ScriptFullPath)oÝ÷ Ù©Ýjëh×6  FileDelete(@AutoItExe)oÝ÷ Ù©ò×ßÛ?ªê-,µçfj|­g¬jëh×6Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '" > nul' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

how would I go about making it delete itself if I didnt know the name of the file?

What do you think this Func does ?

oh ... and make sure you understand it before using it ...

:shocked:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

What do you think this Func does ?

oh ... and make sure you understand it before using it ...

:shocked:

lol, I keep second guessing myself while trying to figure out what it does...before I go and run it lol hurting my head lol

Dont know what scratch.bat is :(

Edited by Ch1ldProd1gy
Link to comment
Share on other sites

@ScriptFullPath

This does it for you, so you don't need to know the name of the script.

This function just creates a batch file and deletes the script from the batch file.

Edited by lolwut
Link to comment
Share on other sites

If FileExists(@TempDir&"\temp.au3") Then
    FileDelete(@TempDir&"\temp.au3")
EndIf

    $f=FileOpen(@TempDir&"\temp.au3" , 2)
    FileWrite($f , "If (ProcessExists('"&@ScriptName&"')) Then")
    FileWrite($f  , @CRLF)
    FileWrite($f , "    ProcessClose('"&@ScriptName&"')")
    FileWrite($f  , @CRLF)
    FileWrite($f , "EndIf")
    FileWrite($f  , @CRLF)
    FileWrite($f , "FileDelete('"&@ScriptName&"')")
    FileWrite($f  , @CRLF)
    FileClose($f)
    Run(@ScriptName&" /AutoIt3ExecuteScript "&@TempDir&"\temp.au3")
    Exit

kinda like the batch code onli autoit :shocked:

Edited by alexmadman

Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

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