0

Hey there,
I'm interested in how to remove files at system startup.
I have some problems deleting huge (2.5Gb) files and files in use using the delete command.
I thought it might be easier to mark them for deletion and then get rid of them as Windows starts
I have tried adding entries for PendingFileRenameOperations in the registry at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager but with no luck.

Any help is appreciated
/Kejpa

10
Contributors
13
Replies
15
Views
13 Years
Discussion Span
Last Post by tranic4
Featured Replies
  • 1

    If he hadn't fixed it by now, some SEVEN YEARS after the last post in that thread, I doubt it's really proving problematical any more... Read More

0

I'm sorry, I don't know how to do this. I know that you can clear temp files at restart, and temporary internet files when you close Internet Explorer, but aside from that, sorry :(

0

Close the program using such files before attempting deletion.

What are the files in question please? (I don't mean the filenames, I simply mean what the heck are you trying to delete?)

0

The files are not in use. They get created as debug information from a program we've made. In some cases the files get very big when some conditions are met and the program is writing down messages every 500 ms.
The files should be deleted at program shutdown but if it's not a clean shutdown they are'nt (and shouldn't or we would never be able to see what broke the program down)
If there are very many of those big files, almost filling the drive you could typically get 3 minutes wait to delete a single 1Mb file, bigger files even longer waits.

So, my thought was to use deletion on system restart. Add the files to be deleted to a certain registry key and then restart the computer and have the files removed by the operating system. Some services have their files deleted on system restart when uninstalled.

HTH
/Kejpa

0

OK. That's getting a bit out of my league here, but consider this please?

If you want the files retained at shutdown in case they are later needed, then why have them automatically deleted at startup, in which circumstance they'd be gone when you wish to refer to them anyway?


But consider this as a possible solution to your problem. Why not write a simple batch file which would delete the files in question. At regular intervals, you'd only need to press <F8> at startup, and one of the options available for Boot choice is "Safe Mode with Command Prompt" .

Run the batch file from there to delete the files in question, and then reboot to start normally. Doesn't sound too troublesome to me.

*shrugs*

0

OK. That's getting a bit out of my league here, but consider this please?

If you want the files retained at shutdown in case they are later needed, then why have them automatically deleted at startup, in which circumstance they'd be gone when you wish to refer to them anyway?

The problem is when the files get overwhelmingly big and fills up the hard disc, then I want to have them removed.

But consider this as a possible solution to your problem. Why not write a simple batch file which would delete the files in question. At regular intervals, you'd only need to press <F8> at startup, and one of the options available for Boot choice is "Safe Mode with Command Prompt" .
*shrugs*

There's another issue.... It's a dedicated computer. The users are not supposed to press F8, they can't log in normally, they don't know any passwords to the computer. We start the computer, automatically logs them in and starts our program which is the only program allowed to run on the computer. In one of the user forms we have an option to read a file from disk and act based on it and it's here where I want to add to the registry information about which files to delete at next reboot.

We're in quite a strange situation, I'm aware of that ;)

Regards
/Kejpa

0

Like I said - it's a bit outta my league. I really am having trouble seeing why those files can't be attended to before they get out of hand :confused:

0

A there are apps out there that will set files for deletion, but it sounds like you are more interested in "Freezing" the computer. This means that you can boot a machine set it up with your program, load something like deep freeze and tell it this is the state you want the machine in. From there unless you log-in to deep freeze and ask it to thaw [unfreeze] the computer [for maintenance or upgrades or whatever] the machine would allow a user to use the computer opening files saving files whatever [per the permission you set-up for their account obviously] and then when the machine is restarted it is brought back to the freezed state with all files and changes purged. You could say reserve a small 2G partition that is not frozen for logs or whatever and then basically set a scheduled task [to run a batch file] that would then check free space and if it is at such a level then go ahead and either do a del * /s /q or whatever [there are other command line tools for download for file removal and the issue is most likely in partition type. Bear in mind NO FAT partitions will EVER handle a file of OVER 2G well. I recommend you use either the NEWER exFAT or NTFS [even if it warns small paritions [say you set the log partition to ~2G it will say you may not want to use NTFS as it is smaller disregard and still use]. I know your next question will be how do I check a drives free space from a bactch file? The below example will set a variable [%freespace%] to the value of freespace found on Drive C [or whatever if you adjust it] and then you could have a batch say if %freespace% > 2147483648 then del * /s /q [the OS returns sizes in bytes at the command line so 2G*1024=2048MB*1024=2097152KB*1024=2097152 Bytes]. the del * /S /Q means Del all files in this directory and all sub-directories and be quiet don't prompt me to delete each file. Here is the line for finding freespace and setting:
for /f "usebackq delims== tokens=2" %%x in (`wmic logicaldisk where "DeviceID='C:'" get FreeSpace /format:value`) do set FreeSpace=%%x
as found here:http://serverfault.com/questions/68300/check-free-disk-space-using-batch-commands]. The only other comment I have for you is why dont you either have your program write to a "successful" file on shutdowns so that way it could actually again in the batch file say check a text file named success.txt for a value [say 1] and it says ahh since I see a 1 I know the program shutdown nicely and I may purge the logs OR it could say I see success.txt but it does not have the value it should so I know NOT to purge logs [and maybe pop a warning via email or somethign to someone who can fix it]. You could do this at intervals as Windows Does [it writes to a file about every 5 - 30 min so it knows whether or not to sched a disk check on boot [thats how it determines whether that is needed yes] OR you could just have it set the file on a successful exit so you dont have extra disk writing at intervals if that is an issue. That should fix you up.

1

If he hadn't fixed it by now, some SEVEN YEARS after the last post in that thread, I doubt it's really proving problematical any more...

Votes + Comments
Lol
0

Try opening a new text document and make both command file & batch files to delete them on restart.Since they are not in use you can rename folders to the path.(If it won`t let you rename do it in safe mode)For example if you want to delete
C:/Folder one/folder two/anythingNoSpace/Big files/file001.tmp then rename the folders & make both batch and command files to read
Del "C:/Folder-one/folder-two/anythingNoSpace/Big-files/file001.tmp"
Just type the renamed path(s) in a text doc save both with same information as a .cmd & .bat file and drop them in drive C: THEN restart your computer & see if it deletes them.Works for me.

If that does not work then try the direct path.Which for the example would be both a .bat and .cmd file in drive C: With inside reading

Del "C:/Folder one/folder two/anythingNoSpace/Big files/file001.tmp"

put a space between all other files to delete.For example to do a double wipe of all .dat files not needed to be rebuilt on windows restart replace USERNAME with your name found on your computer and save them as both a bat and cmd for a double hit.Like this for both.,(deleting the Temporary Internet Files folder completely allows you to just turn your computer off when a virus is trying to install in it so you can kill it on a restart :=] ) This is what a whole bunch of file and or folders should look like to delete as well.Just make sure each are one line with a space below each.

Del "C:\Documents and Settings\USERNAME\Local Settings\History\History.IE5\index.dat"

Del "C:\Documents and Settings\USERNAME\Cookies\index.dat"

Del "C:\Documents and Settings\USERNAME\Local Settings\Temporary Internet Files\Content.IE5\index.dat"

Del "C:\Documents and Settings\Administrator\Application Data\Microsoft\Internet Explorer\UserData\index.dat"

Del "C:\Documents and Settings\Administrator\Cookies\index.dat"

Del "C:\Documents and Settings\Administrator\Local Settings\Temporary Internet Files\Content.IE5\index.dat"

Del "C:\Documents and Settings\Administrator\Local Settings\History\History.IE5\index.dat"

Del "C:\Documents and Settings\Administrator\UserData\index.dat"

Del "C:\Documents and Settings\USERNAME\Cookies\index.dat"

Del "C:\Documents and Settings\USERNAME\Local Settings\Temporary Internet Files\Content.IE5\index.dat"

Del "C:\Documents and Settings\Local Settings\Cookies\index.dat"

Del "C:\Documents and Settings\Local Settings\History\History.IE5\index.dat"

Del "C:\Documents and Settings\USERNAME\Local Settings\Temporary Internet Files\Content.IE5"

Del "C:\Documents and Settings\USERNAME\Local Settings\Temporary Internet Files"

Del "C:\Documents and Settings\USERNAME\Local Settings\History\History.IE5
\MSHistXXXXXXXXXXX\index.dat"

0

---------- I KNOW THIS IS AN OLD QUESTION BUT PEOPLE STILL WONDER----------
The fastest way to delete any stubborn file is to simply make this cool reg file.
It adds a delete on reboot for any file(s) you select.Make sure the first line is at the very top.Just make a new text document in notepad & insert the code below.Double click the reg file and then go right click and choose to delete the stubborn file on reboot and wa la it`s gone !Give it any name you wish.Remember 1st line very top.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\Delete on reboot\command]
@="CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \"Del %1 OnNextReboot\" /d ^\"cmd.exe /c DEL /F /Q \\\"%1\\\"\" /f\""

[HKEY_CLASSES_ROOT\*\shell\Open]

[HKEY_CLASSES_ROOT\Folder\shell\Delete on reboot\command]
@="CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \"Del %1 OnNextReboot\" /d ^\"cmd.exe /c RD /S /Q \\\"%1\\\"\" /f\""

0

For the delete on reboot to actually work instead of just appearing on a right click of a file the lines MUST be together under each other like this.Sorry for the spaces.Just make a new text document and insert the code below save it as a .reg file double click it then right click and choose delete on reboot any file or folder with files in it you wish to delete on your next reboot.If it doesn`t work for your windows version try just changing the ' Windows Registry Editor Version 5.00 ' part.Hope this helps.I have no problems with it.Deletes all stubborn files...every time.

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\Delete on reboot\command]
@="CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \"Del %1 OnNextReboot\" /d ^\"cmd.exe /c DEL /F /Q \\\"%1\\\"\" /f\""
[HKEY_CLASSES_ROOT\*\shell\Open]
[HKEY_CLASSES_ROOT\Folder\shell\Delete on reboot\command]
@="CMD /E:OFF /C REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\Currentversion\\RunOnce /v \"Del %1 OnNextReboot\" /d ^\"cmd.exe /c RD /S /Q \\\"%1\\\"\" /f\""

0

try with Ccleaner.... ccleaner.com
you can clean several registry software and windows temp check and comment if it's utility... G.Luck !!

and you can modify startup of windows multiselection option and delete or disable some process

clear the bad registry of windows and software

Edited by Psymaik: n/a

0

You could just change the file permissions, it's a lot easier than what you propose.
Besides I tried everything you suggested and it didn't work. Changing the file permissions did.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.