On Error Resume Next
''' Set Registry Hive
Const HKEY_LOCAL_MACHINE = &H80000002
''' This section of code creates the list of user profiles
'''
strComputer = "."
Set objRegistry=GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
''' Create a loop to cycle through the profiles
'''
For Each objSubkey In arrSubkeys
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue _
HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
strValue = strValue & "\Desktop"
''' Delete any file on desktop that is older than one day old
''' Skip the default user desktop (although this may not be necessary)
If NOT strValue ="C:\WINDOWS\system32\config\systemprofile\Desktop" _
Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists(strValue) Then
Set Folder = objFSO.GetFolder(strValue)
For Each File in Folder.Files
If DateDiff("d",File.DateLastModified,Now) > 1 Then _
objFSO.DeleteFile File
Next
End If
End If
Set objFSO = Nothing
Next
Set objRegistry = Nothing
ASKER
ASKER
ASKER
ASKER
Active Directory (AD) is a Microsoft brand for identity-related capabilities. In the on-premises world, Windows Server AD provides a set of identity capabilities and services, and is hugely popular (88% of Fortune 1000 and 95% of enterprises use AD). This topic includes all things Active Directory including DNS, Group Policy, DFS, troubleshooting, ADFS, and all other topics under the Microsoft AD and identity umbrella.
TRUSTED BY