cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
AZHockeyNut
Champion Sweeper III
I do mean remove safely not just delete windows.old /s type of command. I was thinking of some automated way to use the disk cleanup utility (install if not there) and/or powershell. Perhaps leveraging a report that pulls the existence of "windows.old" and/or if the disk cleanup utility feature is present (I forget is that desktop experience or something like that? Thanks in advance
1 ACCEPTED SOLUTION
Esben_D
Lansweeper Employee
Lansweeper Employee
AZHockeyNut wrote:
thanks Sean, any chance you can help figure out how to run a report on assets that shows 1) does it have windows.old and 2 does it have the feature installed to run cleanmgr?


The best way to create this report is to look for a file that will always be in the folder Windows.old. Lansweeper can't check if a folder exists, so you will need to use custom file scanning to see if the file within the folder exists.

I believe the feature needed for cleanmgr is called "Desktop Experience" (based on my google search). Unfortunately, the feature is a sub-feature of "User Interfaces and Infrastructure", and Lansweeper will only scan the main features (not sub-features that are installed). This means that even if "User Interfaces and Infrastructure" is installed, it does not mean that "Desktop Experience" is. The only alternative would be to find a registry key that indicates that it is enabled.

The report below will give back assets which have the feature "User Interfaces and Infrastructure" enabled, and the results of a file scan for a the file C:\Windows.old\filehere.txt, which you will have to change to a file which is always in the Windows.old folder (or subfolder).

Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Userdomain,
Coalesce(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) As icon,
tblAssets.IPAddress,
tsysIPLocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblAssets.SP,
tblFeatureUni.featureCaption,
tblAssets.Lastseen,
tblAssets.Lasttried,
TsysLastscan.Lasttime As LastFileScan,
Case
When TsysLastscan.Lasttime < GetDate() -
1 Then
'Last file scan more than 24 hours ago. Scanned data may not be accurate.'
End As Comment,
tblFileVersions.FilePathfull As PathSearched,
Case tblFileVersions.Found When 1 Then 'Yes' Else 'No' End As FileFound,
tblFileVersions.FileVersion,
tblFileVersions.CreationDate,
tblFileVersions.LastAccessed,
tblFileVersions.LastModified,
tblFileVersions.Lastchanged As LastChanged
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Left Join tblFileVersions On tblFileVersions.AssetID = tblAssets.AssetID
Left Join tsysOS On tsysOS.OScode = tblAssets.OScode
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join TsysLastscan On tblAssets.AssetID = TsysLastscan.AssetID
Inner Join TsysWaittime On TsysWaittime.CFGCode = TsysLastscan.CFGcode
Inner Join tblFeature On tblAssets.AssetID = tblFeature.AssetId
Inner Join tblFeatureUni On tblFeatureUni.featUniID = tblFeature.featUniId
Where tblFeatureUni.featureCaption Like '%User Interfaces and Infrastructure%'
And tblFileVersions.FilePathfull = 'C:\Windows.old\filehere.txt' And
tblState.Statename = 'Active' And TsysWaittime.CFGname = 'files'
Order By tblAssets.Domain,
tblAssets.AssetName,
PathSearched

View solution in original post

4 REPLIES 4
Sean_m_Taylor
Engaged Sweeper III
I am horrible at creating reports, just tried creating one and could not get it to get it to correctly report if the scanned computers had the folder or not. All windows computers will have cleanmgr as it is just opens up disk cleanup.
AZHockeyNut
Champion Sweeper III
thanks Sean, any chance you can help figure out how to run a report on assets that shows 1) does it have windows.old and 2 does it have the feature installed to run cleanmgr?
Esben_D
Lansweeper Employee
Lansweeper Employee
AZHockeyNut wrote:
thanks Sean, any chance you can help figure out how to run a report on assets that shows 1) does it have windows.old and 2 does it have the feature installed to run cleanmgr?


The best way to create this report is to look for a file that will always be in the folder Windows.old. Lansweeper can't check if a folder exists, so you will need to use custom file scanning to see if the file within the folder exists.

I believe the feature needed for cleanmgr is called "Desktop Experience" (based on my google search). Unfortunately, the feature is a sub-feature of "User Interfaces and Infrastructure", and Lansweeper will only scan the main features (not sub-features that are installed). This means that even if "User Interfaces and Infrastructure" is installed, it does not mean that "Desktop Experience" is. The only alternative would be to find a registry key that indicates that it is enabled.

The report below will give back assets which have the feature "User Interfaces and Infrastructure" enabled, and the results of a file scan for a the file C:\Windows.old\filehere.txt, which you will have to change to a file which is always in the Windows.old folder (or subfolder).

Select Top 1000000 tblAssets.AssetID,
tblAssets.AssetName,
tblAssets.Domain,
tblAssets.Username,
tblAssets.Userdomain,
Coalesce(tsysOS.Image, tsysAssetTypes.AssetTypeIcon10) As icon,
tblAssets.IPAddress,
tsysIPLocations.IPLocation,
tblAssetCustom.Manufacturer,
tblAssetCustom.Model,
tsysOS.OSname As OS,
tblAssets.SP,
tblFeatureUni.featureCaption,
tblAssets.Lastseen,
tblAssets.Lasttried,
TsysLastscan.Lasttime As LastFileScan,
Case
When TsysLastscan.Lasttime < GetDate() -
1 Then
'Last file scan more than 24 hours ago. Scanned data may not be accurate.'
End As Comment,
tblFileVersions.FilePathfull As PathSearched,
Case tblFileVersions.Found When 1 Then 'Yes' Else 'No' End As FileFound,
tblFileVersions.FileVersion,
tblFileVersions.CreationDate,
tblFileVersions.LastAccessed,
tblFileVersions.LastModified,
tblFileVersions.Lastchanged As LastChanged
From tblAssets
Inner Join tblAssetCustom On tblAssets.AssetID = tblAssetCustom.AssetID
Inner Join tsysAssetTypes On tsysAssetTypes.AssetType = tblAssets.Assettype
Inner Join tsysIPLocations On tsysIPLocations.LocationID =
tblAssets.LocationID
Left Join tblFileVersions On tblFileVersions.AssetID = tblAssets.AssetID
Left Join tsysOS On tsysOS.OScode = tblAssets.OScode
Inner Join tblState On tblState.State = tblAssetCustom.State
Inner Join TsysLastscan On tblAssets.AssetID = TsysLastscan.AssetID
Inner Join TsysWaittime On TsysWaittime.CFGCode = TsysLastscan.CFGcode
Inner Join tblFeature On tblAssets.AssetID = tblFeature.AssetId
Inner Join tblFeatureUni On tblFeatureUni.featUniID = tblFeature.featUniId
Where tblFeatureUni.featureCaption Like '%User Interfaces and Infrastructure%'
And tblFileVersions.FilePathfull = 'C:\Windows.old\filehere.txt' And
tblState.Statename = 'Active' And TsysWaittime.CFGname = 'files'
Order By tblAssets.Domain,
tblAssets.AssetName,
PathSearched
Sean_m_Taylor
Engaged Sweeper III
There is probably an easier way to go about this but the method that I believe can work is this.

Create a unique "cleanmgr /sageset" rule and get the registry created for that and force it on the computers you want and set them off with "cleanmgr /sagerun"

They would be located in regedit "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations"

I do not have any experience forcing registry changes on another computer but I am fairly sure I saw someone created a deployment here that did those so all of this could be created into one deployment.

Information on creating the sageset https://blog.hosebei.ch/2017/11/06/windows-10-remove-windows-old-folder/