Solved

Batch Kill / Delete a file locked by Explorer.exe

Posted on 2009-04-06
5
540 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
[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
  • 2
  • 2
5 Comments
 
LVL 15

Expert Comment

by:zelron22
ID: 24079918
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
ID: 24081013
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
ID: 24081449
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
ID: 24102584
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
ID: 31577506
Thanks for the help.  I used part of your answer as the solution to keep them from creating the extra profiles.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
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.

624 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