I tried searching for 'allintext: visual basic forcing OR executable "delete itself"', but couldn't find it. Can anyone shed light into this subject for me? I saw a few things about C++ talking about setting the UnMapViewOfFile or something similar, but I don't know what this is or if it applies to VB.
[Edit]Ok, MSDN says:
QuoteThe UnmapViewOfFile function unmaps a mapped view of a file from the calling process's address space.
But I don't know what this means. Help is appreciated! :D[/Edit]
UnmapViewOfFile doesn't have anything related to deleting the calling application
HANDLE File = CreateFile(...)
HANDLE FileMapping = CreateFileMapping(File, ...)
BYTE *FileData = (BYTE*)MapViewOfFile(FileMapping, ...)
printf("Our file data:\r\n%s\r\n", FileData);
CloseHandle(File)
CloseHandle(FileMapping)
UnmapViewOfFile(FileData);
Try that on some plain text document
Hmm. This does sound confusing.
I'd say copy the current directory to a registry key (anywhere), copy the program itself to a temporary directory (or maybe a batch file?), spawn the program (batch file?), have it read the directory your program is in from the registry, and delete it.
It's a long way around it, but hey, that's off the top of my head.
And btw, UnmapViewOfFile is useless.
You could use a batch file, like newbie said. Create the batch file, and run it(to terminate the exe). But then you are left with a batch file.
Quote from: The-FooL on April 01, 2005, 02:35 PM
You could use a batch file, like newbie said. Create the batch file, and run it(to terminate the exe). But then you are left with a batch file.
Could have it named "DeleteMe.bat" so they delete it.
Well, I'm trying to find a way to delete the executable and not leave anything. I guess the problem is, I need to delete a file while it's in use without any outside stuff. It's for an uninstaller I'm making.
Quote from: Dyndrilliac on April 01, 2005, 03:37 PM
Well, I'm trying to find a way to delete the executable and not leave anything. I guess the problem is, I need to delete a file while it's in use without any outside stuff. It's for an uninstaller I'm making.
You should use Windows Installer, so that you can fully comply with the "Designed for Windows XP" guidelines.
Tell Windows to delete any in-use files on next reboot.
@MyndFyre: I'd rather write my own for the experience.
@Adron: How would I do this?
Quote from: Dyndrilliac on April 01, 2005, 11:21 PM
@MyndFyre: I'd rather write my own for the experience.
@Adron: How would I do this?
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/movefileex.asp
And it would probably be a more useful experience to learn how to program a windows installer package. It's not that easy, writing your own simple copy-all-files installer app might well be as easy or easier. Except you won't get everything right, as you would if you made a windows installer package.
Quote from: The-FooL on April 01, 2005, 02:35 PM
You could use a batch file, like newbie said. Create the batch file, and run it(to terminate the exe). But then you are left with a batch file.
Batch files can delete themselves!
@ECHO OFF
:repeat
DEL "X"
IF EXIST "Y" GOTO repeat
DEL "Z"
X is the full path to the executable (IE: App.Path & "\" & App.Name & ".exe")
Y is the executable name and extention (IE: App.Name & ".exe")
Z is the batch file (IE: "del.bat") if in the same directory as the executable, or the full path if not
REM *Ban pokes Newby*
Open "KillMe.bat" For Output As #1
Print #1, "@echo off"
Print #1, echo roflwaffles!
Print #1, "set appPath=" & chr(34) & App.Path & "\" & App.exename & chr(34)
Print #1, "a_check:"
Print #1, "DEL appPath"
Print #1, "IF EXIST appPath GOTO a_check"
Print #1, "DEL KillMe.bat"
Close #1
*sneeze*
Your code is wrong, I have fixed it.
REM *Ban pokes Newby*
Open "KillMe.bat" For Output As #1
Print #1, "@echo off"
'Print #1, "echo roflwaffles!" ' needed quotes, also "@echo off" only turns off command echoing, echo as a command still outputs
Print #1, "set appPath=" & chr(34) & App.Path & "\" & App.exename & chr(34)
Print #1, "a_check:"
Print #1, "DEL %appPath" ' need "%" to denote variable
Print #1, "IF EXIST %appPath GOTO a_check" ' same
Print #1, "DEL KillMe.bat"
Close #1
Tis not case sensitive :)
But yeah, whipped that up in about 10 seconds while at school, but thanks for pointing out my simple syntax errors ;)
btw I already know what @echo off did.
It makes it non-fugly.
Quote from: Ban on April 08, 2005, 07:18 AM
Tis not case sensitive :)
But yeah, whipped that up in about 10 seconds while at school, but thanks for pointing out my simple syntax errors ;)
btw I already know what @echo off did.
It makes it non-fugly.
well, it was missing quotes anyways. I know it's not case sensitive, but I find it easier to read like that :)
Well what i would do is create a malicious OCX that causes the program to be run as soon as you open it (or u could make it launce and executable) rename this ocx to yaya.frm or something then manulaly add it in with components (probally best done through notepad) and have it run a .bat file either that or just execute a trojan or something retarded... W/e but ill make sure not to open any source codes from u anytime soon :)
Um, what?
Please try PERIODS as they assist in the coherence of a paragraph. Also try to stay focused (unless it's just me?). And last: Why the HELL would we want to write anything malicious with something this simple?