Solved

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

Posted on 2011-02-22
6
3,876 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 
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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
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 to another domain controller. Log onto the new domain controller with a user account t…

751 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