Page 1 of 1
Delete file on next startup
Posted: Fri Apr 25, 2008 6:42 pm
by abc123
This i searched and had no luck! Keywords: Delete on Startup, File on Startup...
How do i get a file to be delete in the temp folder on the next startup/login?
Posted: Fri Apr 25, 2008 6:48 pm
by Fluid Byte
Write a little commandline tool, specify the filename and put it in the autostart folder. You can also edit the registry: "Run" & "Run Once"
Posted: Fri Apr 25, 2008 6:48 pm
by rsts
Did you try the manual?
Deletefile, Deletedirectory?
cheers
Posted: Fri Apr 25, 2008 8:35 pm
by Trond
rsts wrote:Did you try the manual?
Deletefile, Deletedirectory?
cheers
Did you read the question?
Posted: Fri Apr 25, 2008 10:19 pm
by eJan
@abc123 look here:
http://www.purebasic.fr/english/viewtopic.php?t=20184
Code: Select all
For current user use Registry Key: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
For all users use: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
This is exported Registry when Kaspersky starts with Windows:
Code: Select all
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"AVP"="\"C:\\Program Files\\Kaspersky Lab\\Kaspersky Internet Security 7.0\\avp.exe\""
Edit:
Thanks
iNX, i have found something:
Code: Select all
; MSDN: http://msdn2.microsoft.com/en-us/library/aa365240(VS.85).aspx
; MSDN: http://support.microsoft.com/kb/140570
; Move szSrcFile To szDstFile Next time system is rebooted
; MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
;
; Delete szSrcFile Next time system is rebooted
; MoveFileEx(szSrcFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)
; [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager]
; "PendingFileRenameOperations"=
Procedure ReplaceFile(sSourceFile.s, sDestFile.s)
;SetFileAttributes_(sSourceFile, #FILE_ATTRIBUTE_NORMAL)
MoveFileEx_(sDestFile, #Null, #MOVEFILE_DELAY_UNTIL_REBOOT);
MoveFileEx_(sSourceFile, sDestFile, #MOVEFILE_DELAY_UNTIL_REBOOT)
ProcedureReturn 1
EndProcedure
ReplaceFile(sSourceFile.s, sDestFile.s)
Use:
Code: Select all
MoveFileEx_(sDestFile, #Null, #MOVEFILE_DELAY_UNTIL_REBOOT)
Posted: Sat Apr 26, 2008 2:35 pm
by bingo
for vista !
use:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce
* no admin required (no uac-prompt !)
cmd.exe /c rd /s /q c:\your_folder
or
cmd.exe /c del /f c:\your_file.xxx
simple , but efficient

Posted: Sat Apr 26, 2008 4:21 pm
by iNX
if you're familiar with windows API, you could use moveFileEx that does exactly what you need, with a single call.
Code: Select all
BOOL MoveFileEx(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName,
DWORD dwFlags
);
If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT and lpNewFileName is NULL, MoveFileEx registers the lpExistingFileName file to be deleted when the system restarts. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
Posted: Sat Apr 26, 2008 4:46 pm
by Mistrel
That's great, iNX. I never knew you could do that.
