Jump to content
Sign in to follow this  
Ch1ldProd1gy

How can I delete a .exe....

Recommended Posts

Jos

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

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Ch1ldProd1gy

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

Share this post


Link to post
Share on other sites
Jos

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:


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Ch1ldProd1gy

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

Share this post


Link to post
Share on other sites
lolwut

@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

Share this post


Link to post
Share on other sites
Xand3r

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

Share this post


Link to post
Share on other sites
Ch1ldProd1gy

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

Well, guess I dont need to understand it...it works...thanks lol

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  

×