Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-22
6
Medium Priority
?
4,179 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
Compliance and data security require steps be taken to prevent unauthorized users from copying data.  Here's one method to prevent data theft via USB drives (and writable optical media).
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…
Suggested Courses

704 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