Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to delete subdirectories with random names?

Dec
65
3
In the directory "C:\Windows\System32\config\systemprofile\AppData\Local" there are empty subdirectories whose names follow a format of:

tw-xxxxxxxx.tmp

where the "x" is some random hexadecimal character. When I first noticed this, there were more than 2,000 of them (!!!). After some testing, I found that I can delete them all and it causes no problems. But Windows seems to create new ones at a rate of about 20 a day. (wtf?)

I thought I would automate the process, so I tried to add a line to my startup batch file to delete them. But, the documentation for the RD (remove directory) command says that the /S option (remove subdirectories) doesn't support wildcards. So RD /s tw*.tmp won't work.

I tried doing: del /A:D tw*.tmp

which theorectically should delete everything with the directory attribute set. But that doesn't work either. What am I doing wrong?
 
FOR does support wildcards. You should be able to nuke them with something like:

Code:
for /d %dir in ( C:\Windows\System32\config\systemprofile\AppData\Local\tw-* ) do rd /s /q "%dir"

Maybe insert an ECHO between the DO and RD to test, first.
 
According to Microsoft Co-Pilot...

If the files/folders are named tw-xxxxxxxx.tmp and are appearing under:

C:\Windows\System32\config\systemprofile\AppData\Local

then they are usually not being created by Explorer, TCC, or ordinary applications. They are generally associated with Windows' Provisioning Runtime Tool (ProvTool.exe), which is launched by scheduled provisioning tasks. Multiple reports have traced the creation of these tw-*.tmp folders to that component. [askvg.com], [thegeekpage.com], [learn.microsoft.com]

The commonly reported behavior is:

  • Windows runs ProvTool.exe.
  • The process exits unexpectedly or leaves temporary working folders behind.
  • Empty tw-*.tmp folders accumulate over time.
  • The folders can be deleted safely when they are empty. [askvg.com], [thegeekpage.com], [learn.microsoft.com]
To see whether this is your case, check whether the folders are located in the path above. If they are, the likely source is the scheduled task:

Task Scheduler Library
Microsoft
Windows
Management
Provisioning
particularly the Logon provisioning task that runs ProvTool.exe. [askvg.com], [thegeekpage.com]

To identify the creator with certainty on your machine:

  1. Note the creation time of a newly created tw-*.tmp folder.
  2. Open Event Viewer.
  3. Check:
    • Windows Logs → Application
    • Applications and Services Logs → Microsoft → Windows → Provisioning
  4. Look for ProvTool.exe events at the same timestamp. Reports indicate these folders often appear when ProvTool.exe logs errors such as 0x8007042B. [askvg.com], [thegeekpage.com]
If you want to stop them from being created, the commonly suggested workaround is to disable the provisioning Logon scheduled task, although that modifies Windows provisioning behavior and may have side effects. The sources describe this as a workaround rather than an officially documented Microsoft fix. [thegeekpage.com], [sekin.in]

Joe
 
I used DO (otherwise as @Charles Dye suggested) to get rid of over 1100 of them ... took over 3 minutes. IIRC there's a way to speed up file and directory deletions. ... ???
 
I used DO (otherwise as @Charles Dye suggested) to get rid of over 1100 of them ... took over 3 minutes. IIRC there's a way to speed up file and directory deletions. ... ???

I had 3,128 on my laptop at home. RD /S in a FOR loop removed them all in about 4½ seconds.

I think something must be going on with your system.
 
Vince, do you by any chance have "Delete to Recycle Bin" enabled? It's under OPTION / Startup.
 
Back
Top