On Wed, 18 Jan 2006 23:29:00 -0500, Ted Green wrote:
>>[Deleting Vedit's temp files automatically]
>
>A simpler way would be to place a command in the
>"RunOnce" section of the registry which deletes
>these files on the next reboot.
Oh, yes the registry. Good idea.
(I don't like the registry and so usually I don't think about using it by myself...)
After playing around with some ideas I'm now no longer thinking that an automatic deletion is a good plan.
It is not easy to make it absolutely foolproof and errorfree.
And deleting files via wildcard may have unwanted results...
Anyway, here are some snippets for other people's playing.
Something like the following may reside in VEDIT's USTARTUP.VDM:
// if the RunOnce entry of Vedit doesn't exist in the registry:
// create it
if (Registry_Get_Item (103, "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce\VeditAuto") == -2) {
//---- first determine the summary size if the files in the temp. directory
// Oops, not so easy, especially if used globally (in different languages)
// (the below used variable TEMP_FILES doesn't exist yet!)
//
// Something like a System("dir TEMP_FILES > outfile", DOS)
// with additional checking of the outfile for the second last line
// e.g. "12 file(s) 12.346.346 Bytes"
// should make it possible.
// if (Summary size greater_than configurable threshold) {
//---- let Windows simply delete the files at next reboot (oh, oh!)
// (the below used variable TEMP_FILES doesn't exist yet!)
Reg_Set(103, TEMP_FILES)
Registry_Set_Item("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce\VeditAuto=cmd /c delete |@(103)\*.*")
//------- or
//---- let Vedit do some work at next reboot
// (the below called macro ClearTemp.vdm has to be created, of course)
Reg_Set(103, VEDIT_EXE)
Registry_Set_Item("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce\VeditAuto=|@(103) -q -x ClearTemp.vdm")
//------- or
//---- let start Explorer at next reboot with the temp. directory in focus
// and let the user decide what to do with the files
// (the below used variable TEMP_FILES doesn't exist yet!)
Reg_Set(103, "%windir%\explorer.exe /e,")
Reg_Set(103, TEMP_FILES, APPEND)
Registry_Set_Item("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Runonce\VeditAuto=|@(103)")
}
}
Use at your own risk!
Christian