Thats it really..:)so, can it?

thanks.
Posted on 2001-09-19 08:08:25 by Ray
if u mean, the file that serve to launch it.... yes, and in a different way,
Posted on 2001-09-19 10:01:22 by Sabeel
There is an article in MSDN that tells you how.

I don't remember which one though
Posted on 2001-09-19 23:04:59 by Torch
Try the DeleteFile API. It will delete *any* file under 9x/ME
Posted on 2001-09-20 00:48:50 by huh
ok...
huh: you mentioned win98/me. how about NT?

sabeel: how?:)

thanks.
Posted on 2001-09-20 01:41:04 by Ray
There's an example program at EliCZ's Site, he doesn't provide any source code, though.
Posted on 2001-09-20 09:12:42 by Tola
The only really well-working method for a process to delete the
executable file that launched it, is to create a batch file. All other
methods are very dirty, and might not work on all windows versions.
Batch files can delete themselves :), even though you'll get a "batch
file missing" error... which isn't so bad.
Posted on 2001-09-20 09:23:27 by f0dder
here's the article from msdn
Posted on 2001-09-22 08:41:32 by Sabeel
That was a pretty smart way of doing it... I am impressed with what
some people can come up with. Wehoo, I have learned something new :D
Posted on 2001-09-22 09:49:53 by f0dder
I once worked this out, but when I finally got it working and ran it... I lost all my work.




;----------------------------------------------------------------------------------
DeleteExecutableBF PROC
; This procedure will delete the executable file it is in
; Adapted from : Microsoft Systems Journal, Jan, 1996. "Win32 Q & A," Jeffrey Richter
;
; dependencies:
;
; include \masm32\include\windows.inc
; include \masm32\include\kernel32.inc
; include \masm32\include\shell32.inc
; include \masm32\include\user32.inc
;
; includelib \masm32\lib\user32.lib
; includelib \masm32\lib\kernel32.lib
; includelib \masm32\lib\shell32.lib
;

LOCAL hfile :DWORD
LOCAL len :DWORD
LOCAL hHeap :DWORD
LOCAL pszUnsetupPathname :DWORD
LOCAL pszUnsetupPath :DWORD
LOCAL pszBatFilePathname :DWORD
LOCAL pBatFile :DWORD

jmp nextcode

szBatFileName BYTE "DelUS.bat", 0
szOpen BYTE "open", 0
szBKSlash BYTE "\", 0
L1 BYTE ":Repeat", 13, 10, 0
L2A BYTE "del """, 0
L2B BYTE """", 0
L3A BYTE 13, 10, "if exist """, 0
L3B BYTE """ goto Repeat", 13, 10, 0
L4 BYTE "rmdir """, 0
L5 BYTE """",13, 10, "del """, 0
L6 BYTE """",13, 10, 0

nextcode:
; get some space for strings, and assign pointers to them
invoke GetProcessHeap
mov hHeap, eax
invoke HeapAlloc, hHeap, NULL, 4 * MAX_PATH + 1000
mov pszUnsetupPath, eax
add eax, MAX_PATH
mov pszUnsetupPath, eax
add eax, MAX_PATH
mov pszUnsetupPathname, eax
add eax, MAX_PATH
mov pszBatFilePathname, eax
add eax, MAX_PATH
mov pBatFile, eax


; Create a batch file that continuously attempts to delete our executable
; file. When the executable no longer exists, remove its containing
; subdirectory, and then delete the batch file too.

; get the path to the temp file area
invoke GetTempPath, MAX_PATH, pszBatFilePathname

invoke lstrcat, pszBatFilePathname, ADDR szBatFileName
invoke CreateFile, pszBatFilePathname, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL or FILE_FLAG_SEQUENTIAL_SCAN, NULL
mov hfile, eax
.IF (hfile != INVALID_HANDLE_VALUE)

; Get the full pathname of our executable file.
invoke GetModuleFileName, NULL, pszUnsetupPathname, MAX_PATH


; Get the path of the executable file (without the filename)
invoke lstrcpy, pszUnsetupPath, pszUnsetupPathname

; Find the last backslash '\' and change it to zero
mov edx, pszUnsetupPath
mov ecx, edx
.REPEAT
mov al, BYTE PTR [edx]
.IF al == 92 ; "\"
mov ecx, edx
.ENDIF
inc edx
.UNTIL al == 0
mov BYTE PTR [ecx+1], 0

; Construct the lines for the batch file.
; :Repeat
; del "C:\Win95ADG\UNSETUP.EXE"
; if exist "UNSETUP.EXE" goto Repeat
; rmdir "C:\Win95ADG"
; del "c:\%temppath%\DelUS.bat"
invoke lstrcat, pBatFile, ADDR L1
invoke lstrcat, pBatFile, ADDR L2A
invoke lstrcat, pBatFile, pszUnsetupPathname
invoke lstrcat, pBatFile, ADDR L2B
invoke lstrcat, pBatFile, ADDR L3A
invoke lstrcat, pBatFile, pszUnsetupPathname
invoke lstrcat, pBatFile, ADDR L3B
invoke lstrcat, pBatFile, ADDR L4
invoke lstrcat, pBatFile, pszUnsetupPath
invoke lstrcat, pBatFile, ADDR L5
invoke lstrcat, pBatFile, pszBatFilePathname
invoke lstrcat, pBatFile, ADDR L6

; Write the batch file and close it.
invoke lstrlen, pBatFile
mov len, eax
invoke WriteFile, hfile, pBatFile, len, ADDR len, NULL
invoke CloseHandle, hfile

; now run our bat file in the background
invoke ShellExecute, NULL, ADDR szOpen, pszBatFilePathname, NULL, NULL, SW_HIDE

.ENDIF
; be good and free the heap
invoke HeapFree, hHeap, NULL, pszUnsetupPath
return:
ret

DeleteExecutableBF ENDP
Posted on 2001-09-22 23:03:04 by Ernie
I think the FILE_FLAG_DELETE_ON_CLOSE approach is cleaner...
Posted on 2001-09-23 09:45:19 by f0dder
Great!

thanks to all :))))
Posted on 2001-09-24 02:48:30 by Ray