|
-
Aug 3rd, 2004, 02:21 PM
#1
Thread Starter
Fanatic Member
Delete EXE
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?
-
Aug 3rd, 2004, 03:11 PM
#2
Re: Delete EXE
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?
nope
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"
-
Aug 3rd, 2004, 03:15 PM
#3
You can as good as have the exe delete itself, create a batch file and delete it via that.
-
Aug 3rd, 2004, 03:19 PM
#4
But then you are left with the batch file.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2004, 03:37 PM
#5
Addicted Member
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
-
Aug 3rd, 2004, 03:45 PM
#6
all that code does is create a batch file to delete the file
-
Aug 3rd, 2004, 03:46 PM
#7
It still leaves a batch file for each time you run it.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 3rd, 2004, 04:02 PM
#8
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.
-
Aug 3rd, 2004, 04:24 PM
#9
Frenzied Member
uhhh....... in another exe (resource file)
could you just have in formunload
kill app.path & "\exename.exe"
?
ice
:::`DISCLAIMER`:::
Do NOT take anything i have posted to be truthful in any way, shape or form.
Thank You!
--------------------------------
"Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
"Finaly I can look as gay as I want..." - NoteMe
Languages: VB6, BASIC, Java, C#. C++
-
Aug 3rd, 2004, 04:43 PM
#10
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
-
Aug 3rd, 2004, 04:52 PM
#11
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
-
Aug 3rd, 2004, 06:12 PM
#12
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|