Sign in to follow this  
Followers 0
rudika

Can an AU3 compiled EXE-file delete itself?

13 posts in this topic

Moin, moin...! :lmao:

Is there a possibility that a compiled EXE-file deletes itself after its execution?

I would like to write an uninstallation routine for a program, which does not leave any remainders on the harddisk, therefore the Uninstall.exe must delete itself and the including directory. Is that possible?

Thank you for help.

Greets Rudika


[font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font]

Share this post


Link to post
Share on other sites



Moin, moin...! :lmao:

Is there a possibility that a compiled EXE-file deletes itself after its execution?

I would like to write an uninstallation routine for a program, which does not leave any remainders on the harddisk, therefore the Uninstall.exe must delete itself and the including directory. Is that possible?

Thank you for help.

Greets Rudika

posted a long time ago by ?? and is part of the abbrevs in SciTE:

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @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                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

posted a long time ago by ?? and is part of the abbrevs in SciTE:

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'del "' & @ScriptFullPath & '"' & @CRLF _
            & 'if exist "' & @ScriptFullPath & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc

~Works fine for me :lmao:

I guess this answers your question rudika. lol.

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

All That? Why not just do this?

Func DeleteSelf()
    RUn(@ComSpec & " /k del " & FileGetShortName(@ScriptFullPath), @ScriptDir, @SW_HIDE)
EndFunc

~Works fine for me :lmao:

I guess this answers your question rudika. lol.

Did you try a compiled version ?

Don't think you can DEL a running program..


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

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yeah, i did it with both compiled and uncompiled. It works just fine. Have you tried it?

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

Hi,

your version doesn't work. That is why there is the selfdelete func.

Try this: <-- will not work.

HotKeySet("1", "end")

while 1
    Sleep(1000)
WEnd

Func end()
    MsgBox(0,"","SelfDelete")
    Run(@ComSpec & " /k del " & FileGetShortName(@ScriptFullPath), @ScriptDir, @SW_HIDE)
EndFunc   ;==>end

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

hmm.. I dont understand.. It works just fine for me lol.

I sat here and watched it dissappear off my desktop :lmao:

---oh well.

Edited by CHRIS95219

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Yeah, i did it with both compiled and uncompiled. It works just fine. Have you tried it?

This seems to work pretty good....

But any time the programs takes too long to close down , it will not be deleted...

sleep(50)
Func OnExitFunc()
    
RUn(@ComSpec & " /k del " & FileGetShortName(@ScriptFullPath), @ScriptDir, @SW_HIDE)
EndFunc
Edited by JdeB

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

Share this post


Link to post
Share on other sites

Depends on the speed of your machine. Run() starts...and there is a chance that script will exit before the Run() command actually gets to work. If so it will work. For most people it won't.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Depends on the speed of your machine. Run() starts...and there is a chance that script will exit before the Run() command actually gets to work. If so it will work. For most people it won't.

I´ll thank you everybody.

Correctly, Jon...

I have both tested variants, however only the suggestion of JdeB is practicable, but I have still modified somewhat, so that it delete the whole directory.

But I don´t really understand the ping...

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'rd /s /q "' & @ScriptDir & '"' & @CRLF _
            & 'if exist "' & @ScriptDir & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc

So it works like I wanted. :lmao:

Greets Rudika

Edited by rudika

[font="Comic Sans Ms"][center]Powered by AutoIt3http://www.wik-eric.de/zips/Synchro2.2.2-4free.zip[/center][/font]

Share this post


Link to post
Share on other sites

I´ll thank you everybody.

Correctly, Jon...

I have both tested variants, however only the suggestion of JdeB is practicable, but I have still modified somewhat, so that it delete the whole directory.

But I don´t really understand the ping...

Func _SelfDelete($iDelay = 0)
    Local $sCmdFile
    FileDelete(@TempDir & "\scratch.bat")
    $sCmdFile = 'ping -n ' & $iDelay & '127.0.0.1 > nul' & @CRLF _
            & ':loop' & @CRLF _
            & 'rd /s /q "' & @ScriptDir & '"' & @CRLF _
            & 'if exist "' & @ScriptDir & '" goto loop' & @CRLF _
            & 'del ' & @TempDir & '\scratch.bat'
    FileWrite(@TempDir & "\scratch.bat", $sCmdFile)
    Run(@TempDir & "\scratch.bat", @TempDir, @SW_HIDE)
EndFunc

So it works like I wanted. :lmao:

Greets Rudika

The ping is to keep the program running. That way your program closes before the command "del" is ever executed.

Share this post


Link to post
Share on other sites

But I don´t really understand the ping...

It's workaround for missing Sleep() in DOS batch files :lmao:

Batch file file start deleting/testing successfull delete/loop after some timeout

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