Jump to content

self deleteing can it be done


cammy9.9
 Share

Recommended Posts

  • Developers

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

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

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:

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

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
Link to comment
Share on other sites

  • 4 weeks later...

@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

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