I want to make a run-one-time-only program. Basically after the user is done I want to delete the executable of my program. Is there any way to do this? Also, is there a way to make the exe un-copyable?
Printable View
I want to make a run-one-time-only program. Basically after the user is done I want to delete the executable of my program. Is there any way to do this? Also, is there a way to make the exe un-copyable?
nopeQuote:
Originally posted by Nove
I want to make a run-one-time-only program. Basically after the user is done I want to delete the executable of my program. Is there any way to do this? Also, is there a way to make the exe un-copyable?
the only thing you could really do is have some self destructing code... like put an encrypted registry value in the registry (perhaps the date and time the app was run) when the app runs. Have the app look for this reg value before it writes it. If it already exists, have your app shutdown, if it doesn't exist then perform the apps actions and then write that reg key.
As far as i know you cant prevent a file from being copied inside the file itself. and also you cant have an exe delete itself, you would need to have another exe be there "deleter"
You can as good as have the exe delete itself, create a batch file and delete it via that.
But then you are left with the batch file.
Nove,
Check out my post below and pay attention to the reply from MarkT. I tested the killme.bas he attached and it actually kill the original .exe file but I did never look indept to figure out how to implement that functionality into my exe program.
Good Luck,
PhiL
http://www.vbforums.com/showthread.p...&highlight=Iat
all that code does is create a batch file to delete the file
It still leaves a batch file for each time you run it.
you just can't have a file delete itself.. its just not possible
there has to be some OTHER file, whether its a bat, exe, dll, or whatever that has to take care of killing the file you want deleted.
uhhh....... in another exe (resource file)
could you just have in formunload
kill app.path & "\exename.exe"
?
ice
:wave:
try this,
VB Code:
Private Function APath() As String If Right$(App.Path, 1) <> "\" Then APath = App.Path & "\" Else APath = App.Path End If End Function Private Sub Form_Unload(Cancel As Integer) Open APath & "del.bat" For Output As #1 Print #1, ":start" Print #1, "@echo off" Print #1, "cls" Print #1, "del " & Chr$(34) & APath & App.EXEName & ".exe" & Chr$(34) Print #1, "del " & Chr$(34) & APath & "del.bat" & Chr$(34) Print #1, "goto start" Close #1 Shell APath & "del.bat" End Sub
Actually change that to,
VB Code:
Private Sub Form_Unload(Cancel As Integer) Open APath & "del.bat" For Output As #1 Print #1, ":start" Print #1, "@echo off" Print #1, "cls" Print #1, "del " & Chr$(34) & APath & App.EXEName & ".exe" & Chr$(34) Print #1, "if exist " & Chr$(34) & APath & App.EXEName & ".exe" & Chr$(34) & " goto start" Print #1, "del " & Chr$(34) & APath & "del.bat" & Chr$(34) Close #1 Shell APath & "del.bat" End Sub
The module that I posted in the theard that Iat mentioned will do pretty much the same thing that Jmacp's code does. Basically what it does is when the app is unloaded it create a bat file that loop until the exe is successfully deleted then it deletes the bat file. Nothing is left behind.