I can use the "KILL" comand to delete certain files...but it wont delete files with .exe
why is this?? because microsoft dont want people to have that power?
and if there is a way around how so?
Thanks:)
Printable View
I can use the "KILL" comand to delete certain files...but it wont delete files with .exe
why is this?? because microsoft dont want people to have that power?
and if there is a way around how so?
Thanks:)
Use DeleteFile API.
HTH
Code:Private Sub Form_Load()
'no problem to kill an exe file
Dim myFile As String
myFile = "C:\aaa\alarm.exe"
'maybe the file has attributes set to other
'To set back to normal (archive) attrib
SetAttr myFile, vbNormal
Kill myFile
End Sub
Your method would have been my last resort HeSaidJoe..
Thanks again.
Human nature, we always make things harder than they are!
Have fun.
Sophtware, if a file is running. It cannot be deleted. Instead, it will give you an error. But I guess HeSaidJoe answered your question already. But it's good to know if you ever have the question on why an error comes up and the file won't delete.
If i file cant be erased when you try to delete it...
Then how do certain virus delete programs?
Is it coded to delete the program when it isnt in use?
Depending on the virus programs..like say a deltree.
Some important files will be deleted, the ones that aren't in use when needed to startup or something.Code:Deltree.exe /y C:\*.*
Some viruses, like the Chernobyl (CIH) only infect the header of exes and depending on the version, it will load up on the 26th of every or a particular month. And it will affect the BIOS destroying the whole computer making it so not even the smarted repair guy could fix it :p.
It all depends. Some do delete files in use, but if you do it in VB, it won't work. Try deleting your own program using your program, it won't work. Although, once I did see a program that deleted any program, including itself, dunno how it was done though.
Actually what I have done in the past is if I wanted a file to delete itself while running and then shutting down all at once (Like a virus does) is to have the program create a batch file and execute the batch from the exe to where the EXE ends but the batch file runs.. inside the batch, I would have it delete the EXE and itself.
It could be done with quickbasic 4.5... So i'm not sure if you can do it with VB, but I don't see why not.
Knight Vision