Jump to content

Disk Cleanup not really working


Recommended Posts

I'm having a hard time with Disk Cleanup and autofix, and not getting any good help from Labtech.

 

Essentially all I want is to have happen is:

 

1. LT scans temp folders that I choose (or at a minimum, %USERPROFILE%\temp and %windir%\temp) and figures out the size.

 

2. When the size is greater than a threshold (say 500MB), run the autofix action to delete the temp files in the scanned directories.

 

3. Have the script then check size again, and if under 500MB, update and close the ticket.

 

Really none of it's working and hard for me to troubleshooot, the C:\Windows\LTSvc\DiskCleanup.txt log file just shows it scanned a bunch of directories but delete actions.

 

-----------------------------------------------------------------------------------------------------------------------

tempfiles variable

I see the Disk Cleanup monitor checks the variable tempfiles in the database, but I can't tell how it's calculating the number it puts in that variable. For example, one computer generated a ticket that says:

 

Disk Cleanup needs to be performed on domain\WORKSTATION1 at Main office.

TempFiles: 2649287066bytes (2.64 GB)

 

On that computer, there is 936MB of temp files dated in the last few years in the AppData\Local\Temp folder. I confirmed I can manually delete some of the older ones (like files from Aug 2016) so I know they are not all locked.

 

And then I have C:\Windows\Temp is 2.91GB though, so, whatever number the monitor is reading, isn't including C:\Windows\Temp I am assuming, but really not sure why.

 

My Dashboard > Config > Configurations > Disk Cleanup shows (among others)

 

%WINDIR%\temp

 

And i verified via CMD and running the SET command that the variable %WINDIR% is set to C:\Windows, which is correct.

 

------------------------------------------------------------------------------------------------------------------------------

 

I was told the Dashboard > Config > Configurations > Disk Cleanup hold the settings (directories) for the Disk Cleanup script and commands. However, I can't tell how those settings make it into a SAGERUN configuration (anyone who knows cleanmgr.exe command line knows what I'm talking about here). I see the disk cleanup script runs cleanmgr.exe with /sagerun:1 , but, how does the config for get into configuration? I feel like that part isn't working either.

 

Thanks in advance, I have to assume most of you out there have this working like a champ in Labtech, as to me it's core functionality for any MSP offering.

Link to post
Share on other sites

I have considered using cleanmgr with sageset and sagerun. You would have to create a set on a computer and then script out registry edits to recreate the set on your agent PCs. I don't know if different versions of Windows using different registry keys or values.

Link to post
Share on other sites

After working with Labtech support, I found they have the same access to documentation that I do, therefore, some of my questions are unanswered.

 

There is no documentation on what directories it queries to determine how many "temp files" are present on a system. It does report a number to the database, but no way to tell how it's calculated.

 

Useless.

 

Also, it looks like the script has nothing to do with the Dashboard config for Disk Cleanup.

 

They did state the "Command" for Disk Cleanup should run off the config in the Dashboard cleanup, but I have not verified that yet.

 

I also did have an issue with credentials, which may be part of why my troubleshooting was yielding little results. Run the #whomami from the command prompt on an agent to determine if you have proper credentials.

 

The final solution i was given was "script it yourself" or "get the CCleaner plugin" which is an additional cost, but might be worth it given the severe limitations and lack of information on the Labtech disk cleanup side.

 

Thinking of switching to something else, as my experience with support has been really bad for the last year and half. There's really only one person I've worked with at Labtech that is willing to help, the rest just want to give you a link and close your ticket.

  • Like 1
Link to post
Share on other sites
  • 3 years later...

Old ticket but I thought I would add what I found:

The disk cleanup has 2 scripts, Disk Cleanup and Disk Clean Setup. The Setup script adds a bunch of reg keys in the HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches area of the registry. This is where cleanmgr.exe looks (so presumably that's what gets set when you run /SAGESET 

However I still haven't found any correlation between the Disk Clean scripts and the folders listed in the Dashboard\Config\Disk Clean tab. There is a log file in the LTSvc folder that lists all the folders and subfolders that match the Disk Clean settings from the dashboard which seems to indicate the agent has done something with that config, but the folders are still present on the end point and yep, looks like cleanmgr knows nothing of it. I'll keep digging...

Link to post
Share on other sites

updating this with more discoveries. After spending an hour with support their tier1 guys obviously have no idea how the disk cleanup works. I'm now waiting for a tier 2 call back.

So I have discovered that the disk cleanup COMMAND is the one that uses the Dashboard\Config\Disk Cleanup tab settings. The DRV - Disk Cleanup Server monitor has the alert template 'Autofix action temp file cleanup' set on it. The alert template runs the disk cleanup script, which calls the 'disk cleanup setup' script. The disk cleanup setup script installs the Desktop Experience feature then checks if it's installed (if it needs a restart it will detect it as not installed and exit (so until that server is restarted the script will just run and retry the feature install and exit), this is despiute the fact that cleanmgr.exe is installed and is available). Once the feature check returns true, the script carries on and runs a dir command to find where cleanmgr.exe lives under the windows\winsxs folder structure. Unfortunately in my case, and I suspect in many, the results of the dir command includes multiple folders that contain cleanmgr.exe  (various versions) and the script assumes the dir command returns just 1 folder. The script then attempts to Copy the cleanmgr.exe file from a source directory (the result of the previous dir command), to the Windows\System32 directory. Looking on the server I can see it fails with an error ERR invalid path. While I could fix it, I'll wait for Tier 2 support to get back to me so we can try to get the product issue resolved.

 

So @labtechagent, I would first check the end points and see if they show the disk cleanup script running on them. If they do, check the command history for that end point and see if it's running the Disk Cleanup command. Also, you can try manually running the Disk Cleanup command on the server to see if it works. The end points should have a file windows\ltsvc\diskcleanup.log that will have either Delete details, or Scanning details. Unfortunately, this log file is overwritten by Resend System Information (and I suspect Resend Storage Information). I believe it's that process that runs the disk cleanup tool in scan mode and returns the tempfiles result you see in the database. So, once you run the disk cleanup command manually, have a look at the file and check it shows deleting entries. Back it up if you want to review it, as the next resend system information command that runs will overwrite it.

 

Edited by cyn3rgy
updated information - confirmed disk cleanup command does run in the disk cleanup script.
Link to post
Share on other sites

Disk cleanup hasn't really worked/poor implementation since LT11 🤣 (clarification: citing LT11 because that's when my focus was set on this) we just made our own disk cleanup script instead.

Edited by BlueToast
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...