Question
October 19, 2007 at 05:28 AM
laguna_7

Cleanup via Shutdown

by laguna_7 . Updated 19 years ago

Hi,

I am an engineer for a large multi-national. One of the clients who’s site I work on has a requirement for us to setup a “cleanup via shutdown” concept which will basically do as the name says. Cleanup while shutting down. We have a little application called: “Delprof” which is designed to delete old user profiles as alot of our users hotdesk it in our office so many of our pc’s have unecessary amounts of unused profiles on them. Delprof uses the “Ntuser.dat” files to decide if the profile is old by looking at the date that it was last accessed.

This needs to be run from a command prompt probably via shutdown when the log off scripts run. Thats the first application.

Then in the same shutdown sequence we want to run an automated instance of “Cleanmgr.exe” to cleanup the desktop of unnecessary temporary files and the like. Problem is that when you run cleanmgr it requires you to create a reference point into the registry so that it knows what settings to use. By running the application and using the “/sageset: n” switch where n is any number between 0 and 65536, you can save into the registry the template of what you want cleanmgr to delete when it gets run and this can be done by using the “/sagerun: n” switch where n, again, is the same number you chose when creating the so called template.

This presents a problem because how do I create a batch file to call this application into operation after delprof has run (bearing in mind that delprof and a few other applications need to be part of this batch file) and how do I get cleanmgr to create a template in the registry first and then run that template? Obviously there needs to be a template first otherwise cleanmgr won’t know what to delete. No where on Microsoft’s website can I find info on how to use this application on multiple machines at the same time. I understand the switches and how to use them but my problem is that I’m trying to call and application by writing into a batch file say the following:

Call C:\Windows\System32\cleanmgr.exe /sageset:1

This will create the template and then when thats done I need to somehow create a long enough pause in the batch file’s run so that this string runs and completes before any other part of the batch file gets envoked. Then to complicate matters even more, creating the template is one thing but how do I specify the setting on what to delete when I’m not even there? Because obviously if we roll this out in a corporate environment, I won’t be at every pc to set the requirements for the template when this batch file runs. I need to automate this so it set automatically what to delete and continues without user intervention. I don’t know if this can be done.

If this can be done then somehow I’ll need to call the “sagerun: n” part of the batch file but again, it must only run after the initial phase is completed, I have no idea how to make a batch file pause at one line till finished then go on to the next.

This seems to be a big headache for me because I just can’t see any way around this. If there’s a guru among any of you that has the patience and is kind enough to help me figure this out I will be oh so grateful, I hope all of this makes sense…

There are other applications like “VPScan” for antivirus and the “Defrag” function that also needs to run as part of this batch file but I guess we can get to that later.

Thank you to anyone who takes the time to read this helps me make sense of it…

This discussion is locked

All Comments