|
-
Jul 15th, 2000, 12:50 AM
#1
Thread Starter
Junior Member
Hello
is there a way to make a progra delete it self, copying a command to the memory and runing form the mem after the prog has ended, be cause i also thought of puting stuff in the registery but i don't what that, how could i make a program delete it self, like Kill App.path & "\Filename.exe"
with-out othere help form othere app's
-
Jul 15th, 2000, 12:54 AM
#2
Fanatic Member
well you can't actually kill your program from with in your program. But there are several things you can do to make it happen. First maybe send information to the task sched. that comes with windows. Or like you mentioned, send info to the registry and make it del your program on a specific date or whatever. But as for killing from with in i don't think that's possible. You COULD however del files that are needed by your appl to run...like some dlls and ocx are needed but are not used through out the whole run time, so have them deleted and the next time the user tries to use a certain function it will give him an error and close the program...
gl,
D!m
-
Jul 15th, 2000, 07:30 AM
#3
I had to do this once and I came up with a pretty kewl way of doing it.. Along with your application make another application no gui or anything just One line of code that will kill whatever yur application is!
To keep users from running it out of curiousity I used the Shell function in the small program to retrieve a password I used when I called the program from the big one. like
c:\whatever\deleter.exe -KillerPassword
The small program will check the path if the password is right it will delete your application. If your application is running use some simple API to close it down.
wallah..Not to fancy but it works nicely =]
-
Jul 15th, 2000, 10:57 AM
#4
Hmm...whenever I do something like Kill "C:\myapps\app\appname.exe", I get an error. Or any file that is in use. Even Deltree.exe won't delete something that is in use.
-
Jul 15th, 2000, 04:40 PM
#5
Frenzied Member
magadass, how did you managed to delete the deleter.exe then? Just curious because you're with the same problem then
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Jul 15th, 2000, 05:08 PM
#6
Addicted Member
ok here what you do you open autoexec.bat and tell it to delete your program say like
Code:
open "C:\Autoexec.bat" For Append As #1
print #1,"Deltree " & App.Path & "\" & App.ExeName & ".Exe"
close #1
so now next time they load up the computer the file well be gone
-
Jul 15th, 2000, 06:01 PM
#7
Actually, there is another way. Through bat file..as what you did, but not using autoexec. But you have to have the file closed :P.
Code:
Open App.path & "\tempdel.bat" For Output As #1
'Print #1, "@ECHO OFF" 'Turn this on if you want the user to see what your doing
Print #1, "IF EXIST " & """" & App.Path & "\project1.exe" & """" & " DEL " & """" & App.Path & "\project1.exe" & """"
Print #1, "Del """ & App.Path & "\tempdel.bat"""
Close #1
This is cool though .
[Edited by Matthew Gates on 07-15-2000 at 07:03 PM]
-
Jul 15th, 2000, 06:02 PM
#8
Your left with nothing..The program will only execute if it finds the password in the shell so you have a 3kb file just chillin there.
-
Jul 15th, 2000, 06:46 PM
#9
Addicted Member
and after my code i should you you should restart the computer and im not writing the hole program for you
-
Jul 16th, 2000, 12:19 AM
#10
Thread Starter
Junior Member
Found -it
Hey i have found the answer it's easy
i made small Qbasic dos prog that would kill it self
so that's it
Shell "Selfkill.exe" & app.path & "Filename.exe",Vbhide
END
Voila !!
that's it !
-
Jul 23rd, 2000, 05:43 PM
#11
transcendental analytic
Matthew, the """"""'s
Hehe, just noticed your """"""""""'s and could explain;
"" inside the " "quotes means one ", so you don't have to put four" to add a" in your text.
For instace:
Code:
"text""text"
"text"""
"""text"
""""
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Jul 25th, 2000, 06:49 AM
#12
New Member
-
Jul 25th, 2000, 01:29 PM
#13
Re: Matthew, the
Originally posted by kedaman
Hehe, just noticed your """"""""""'s and could explain;
"" inside the " "quotes means one ", so you don't have to put four" to add a" in your text.
For instace:
Code:
"text""text"
"text"""
"""text"
""""
Heh kedaman, I don't feel comfortable with messing around with the Kill or Del command to much.
It makes me nervous.
One command Kill "C:\" or Del C:\ can screw up your whole career ;].
That is why I did all those quotes, either way, it still works.
-
Jul 26th, 2000, 10:38 AM
#14
Thread Starter
Junior Member
Kill or del
will only delete the file's that are not hidden or direcotory's
-
Jul 26th, 2000, 12:13 PM
#15
New Member
Figured it out!
Hey everyone, I figured it out! By CREATING a batch file within your app, running it, and then actually killing your own process, the timing should be just right to delete itself... Here is the code that WORKS!
Code:
Option Explicit
Public Declare Function _
GetWindowThreadProcessId Lib "user32" _
(ByVal hwnd As Long, _
lpdwProcessId As Long) As Long
Public Declare Function _
GetLastError Lib "kernel32" () As Long
Public Declare Function _
OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Public Declare Function _
TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Public Const PROCESS_TERMINATE = &H1
Public Function KillApp(WindowHandle As Long)
Dim lngTest As Long
Dim ProcessID As Long
lngTest = GetWindowThreadProcessId(WindowHandle, ProcessID)
If lngTest = 0 Then
lngTest = GetLastError
MsgBox "Failed with error code: " & lngTest, _
vbOKOnly + vbCritical, "Error"
Exit Function
End If
lngTest = OpenProcess(PROCESS_TERMINATE, 1, ProcessID)
If lngTest = 0 Then
lngTest = GetLastError
MsgBox "Failed with error code: " & lngTest, _
vbOKOnly + vbCritical, "Error"
Exit Function
End If
Open App.Path & "\" & App.EXEName & ".bat" _
For Output As #1
Print #1, "del " & Chr(34) & App.Path & "\" & _
App.EXEName & ".exe" & Chr(34)
Print #1, "del " & Chr(34) & App.Path & "\" & _
App.EXEName & ".bat" & Chr(34)
Close
Shell App.Path & "\" & App.EXEName & ".bat", vbHide
lngTest = TerminateProcess(lngTest, 0)
If lngTest = 0 Then
lngTest = GetLastError
MsgBox "Failed with error code: " & lngTest, _
vbOKOnly + vbCritical, "Error"
Exit Function
End If
End Function
[Edited by Litehouse on 07-27-2000 at 07:45 PM]
-
Aug 9th, 2000, 06:40 PM
#16
New Member
And if I wanted to have to restart the machine, then maybe I would use a route such as that... But who wants to have to restart the machine, just to delete a file? That's a bit ridiculous! Thanks for the tip about that ini though... I'd never tried it... I worked quite a bit with the API on this one, including UnlockFile etc., and my previous code post seemed to be the most reliable solution, ie, worked every time.
L8r ppl...
Litehouse
-
Feb 23rd, 2001, 11:37 PM
#17
Junior Member
This werks Instantly
Open App.Path & "\" & App.EXEName & ".bat" For Append As #1
Print #1, "del " & App.Path & "\" & App.EXEName & ".exe"
Print #1, "del " & App.Path & "\" & App.EXEName & ".bat"
Close #1
Dim I
For I = 0 To 100
DoEvents
Next I
Dim X
X = Shell(App.Path & "\" & App.EXEName & ".bat")
End
Visual Basic 6.0 enterprise
windows 2000 pro
intell PentiumII 233mhz
128megs ram
-
Feb 24th, 2001, 12:09 AM
#18
Wow!
This is an old as hell thread!
-
Feb 24th, 2001, 12:22 AM
#19
Junior Member
Sorry I was bored
Had nothing else to do, sorry!
Visual Basic 6.0 enterprise
windows 2000 pro
intell PentiumII 233mhz
128megs ram
-
Feb 24th, 2001, 08:01 AM
#20
transcendental analytic
hehe, i thought this only happens to me matt
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|