Sign in to follow this  
Followers 0
cammy9.9

self deleteing can it be done

9 posts in this topic

Hi

is there a way of makeing a program that will delete it self after it has ran so the user can only use it once

Share this post


Link to post
Share on other sites



Hi

is there a way of makeing a program that will delete it self after it has ran so the user can only use it once

yes..

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

could any one tell me the code to it ive looked in the help files and i dont have a clue on how to do it

thanks

Share this post


Link to post
Share on other sites

could any one tell me the code to it ive looked in the help files and i dont have a clue on how to do it

thanks

did you even try to search ?

This has been asked so many times ... the key is _SelfDelete() :whistle:


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

a thank you

Share this post


Link to post
Share on other sites


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I always use Larry's SuiCide() function, I think the name is quite funny :whistle:

; IMPORTANT MAKE A COPY OF SCRIPT BEFORE DELETION
; Deletes the running script
; Author Larry

SuiCide()

Func SuiCide()
    $SC_File = @TEMPDIR & "\suicide.bat"
    FileDelete($SC_File)
    $SC_batch = 'loop:' & @CRLF & 'del "' & @SCRIPTFULLPATH & '"'  & @CRLF & _
         'ping -n 1 -w 250 zxywqxz_q' & @CRLF & 'if exist "' & @SCRIPTFULLPATH & _
        '" goto loop' & @CRLF & 'del suicide.bat' & @CRLF

    FileWrite($SC_File,$SC_batch)
    Run($SC_File,@TEMPDIR,@SW_HIDE) 
    Exit
EndFunc

Share this post


Link to post
Share on other sites

thanks bigdod

Share this post


Link to post
Share on other sites

@ChrisL

the function you are using doesn't delete the program folder

i'm using a similar approach

CODE
Func DeleteProgram ()

If FileExists (@TempDir &"\RemoveMe.cmd") then

FileClose (@TempDir &"\RemoveMe.cmd")

FileDelete (@TempDir &"\RemoveMe.cmd")

EndIf

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", "@echo off")

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", ":loop")

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", "del """ & $InstallPath & "\*.*"" /S/Q")

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", "if exist """ & $InstallPath & "\Uninstall.exe"" goto loop")

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", ":Loop2")

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", "rd """ & $InstallPath & """ /Q")

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", "if exist """ & $InstallPath & "\NUL"" goto loop2")

FileWriteLine (@TEMPDIR & "\RemoveMe.cmd", "del " & @TEMPDIR & "\RemoveMe.cmd")

Run (@TEMPDIR & "\RemoveMe.cmd", @TempDir, @SW_HIDE)

Exit

EndFunc

This wil also remove the folder


Best regards,Emiel Wieldraaijer

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