Solved

Batch Kill / Delete a file locked by Explorer.exe

Posted on 2009-04-06
5
526 Views
Last Modified: 2012-08-13
I am writing a script that searches and deletes all profiles out of the C:\Documents and Settings\ folder on all our citrix farm servers.  Here is the basic module breakdown of the script:
1.  Get input folder name
2.  xcacls to remove all inherited permissions / write new permissions (just to make sure...probably not necessary)
3.  Unlock files **
4.  Delete Files
5.  Write to log for verification.


Now, i have found 1 other script that make this work...1 that runs the search / delete / export log.

The problem is...there are some *.tmp files that are locked by explorer.exe that i can not get deleted.  If i use a program like...unlocker.exe, it can delete them, but i cannot get the command line unlock to work with that program.  So, i am needing a way to unlock all files in a folder that i can vbs script call / use.

Thanks in advance for your help.
0
Comment
Question by:KentuckyDataService
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:zelron22
Comment Utility
Are the users still logged on?  Log them off first, then run this.  

That being said, what are you trying to accomplish?  There may be an easier solution.
0
 
LVL 1

Author Comment

by:KentuckyDataService
Comment Utility
No, all users are logged off.  We are trying to clear out the docs & settings folder.  Cause when a profile gets messed up, it creates a new one..ie TEMP, TEMP.000, TEMP.001....

We are just trying to keep that folder cleared...but that UTIL i wrote can't work because a few files are Locked by explorer.exe; though no one is logged in.  We are checking tonight to see if there still is an instance of explorer.exe running....because with no one logged in..there shouldn't be.
0
 
LVL 15

Accepted Solution

by:
zelron22 earned 500 total points
Comment Utility
Have you installed UPHClean?  Also, you can set local profiles to be deleted at log off using group policy.  It sounds like either people are disconnecting instead of logging off (and you can force log off) or that an application is hanging when they log off keeping them from really logging off.

Anything in the event log about hung applications?
0
 
LVL 6

Expert Comment

by:Justin_W_Chandler
Comment Utility
Just an FYI, just because something has a file handle that locks a file, don't assume it's locked by explorer.
0
 
LVL 1

Author Closing Comment

by:KentuckyDataService
Comment Utility
Thanks for the help.  I used part of your answer as the solution to keep them from creating the extra profiles.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

#Citrix #POC #XenDesktop #vCenter #VMware #ESX
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
How to install and configure Citrix XenApp 6.5 - Part 1. In this video tutorial we have explained step by step installation of Citrix XenApp 6.5 Server on Windows Server 2008 R2 is explained in this video. We have explained the difference between…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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