Solved

Disk Cleanup for all user profiles on Terminal Server - Windows 2008

Posted on 2011-02-22
6
3,582 Views
Last Modified: 2012-05-11
I would like to be able to empty all temp directories for all user profiles on our Terminal Server which is running Windows 2008 R2. How do I action this? When I run disk cleanup as the Administrator it only relates to the Administrator profile. I would really like perform some sort of disk cleanup that will affect all the profiles on the Terminal Server.

Any ideas?

Thank you
0
Comment
Question by:the_omnific
  • 4
6 Comments
 
LVL 9

Expert Comment

by:Lester_Clayton
ID: 34950801
There is no single command or folder you can erase to do all profiles on Terminal Servers.  What you'd have to do is list all the folders in the users area, and then systematically remove all temp folders for each directory.

Example : Dir list of C:\Users reveals 5 users named User1, User2, User3, User4, User5

Then, you'd delete the contents of the 5 following folders.

C:\Users\User1\AppData\Local\Temp\4
C:\Users\User2\AppData\Local\Temp\4
C:\Users\User3\AppData\Local\Temp\4
C:\Users\User4\AppData\Local\Temp\4
C:\Users\User5\AppData\Local\Temp\4

Be careful though - If this folder is missing, it will cause issues - only delete the contents of the folders, not the folders themselves.
0
 
LVL 12

Expert Comment

by:prashanthd
ID: 34951252
Hi,

You can try this code
On Error Resume Next
    
    Dim fs, f, f1, fc, s
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFolder("c:\users\")
    Set fc = f.SubFolders
    
    For Each f1 in fc
        temp_path="c:\users\"& f1.Name &"\AppData\Local\Temp\4\*.*"
        fso.DeleteFile temp_path, True 
    Next

Open in new window

0
 
LVL 1

Author Comment

by:the_omnific
ID: 34955324
prashanthd

Please find attached
vberror.jpg
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 1

Author Comment

by:the_omnific
ID: 34955358
Lester_Clayton > You mean don't delete the temp folder itself C:\Users\User1\AppData\Local\Temp but we can delete everything inside it including subfolders without causing issues ?
0
 
LVL 1

Accepted Solution

by:
the_omnific earned 0 total points
ID: 34956141
Thank you for your input guys but I have opted to use CCleaner to run in silent mode in everyone's start-up.
0
 
LVL 1

Author Closing Comment

by:the_omnific
ID: 34990875
I have used a different method that I am happy with.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Resolve DNS query failed errors for Exchange
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now