PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

PDF preview handler (File Explorer) prevents moving or deleting a file on Windows Server share

Open Gen-CA opened this issue 2 years ago • 7 comments

Microsoft PowerToys version

v0.66.0

Installation method

PowerToys auto-update

Running as admin

No

Area(s) with issue?

File Explorer: Preview Pane

Steps to reproduce

  1. Create or view PDF file on remote Windows Server share (this issue doesn't appear to happen on local/OneDrive files).
  2. Then try to move the file from the server share to a local folder.

✔️ Expected Behavior

Expect to be able to move or delete the file.

❌ Actual Behavior

Attempting to move OR delete file: Windows shows a "File In Use" dialog saying "The action can't be completed because the file is open in COM Surrogate. Close the file and try again." Repeated attempts yield the same result, even after restarting Windows, unless the PowerToys PDF preview is turned off and THEN Windows is restarted. Making sure that Adobe Acrobat Reader is closed also has no effect.

The move or delete fails whether attempting with GUI drag-and-drop or with command-line.

image

File Locksmith reports the file to be held by explorer.exe: image

Other Software

Running Windows 11 64-bit Home, version 22H2 (build 22621.1105), although this issue has occurred for awhile including before recent Windows updates.

Gen-CA avatar Jan 21 '23 22:01 Gen-CA

I have this issue on Windows 10. Generate an STL using Solidworks, then try to delete it and it's "open in COM surrogate". I closed Solidworks to make sure that wasn't keeping a lock on the file, but it didn't help. I found a process called COM surrogate in task manager and killed it, and was then able to delete the STL.

jeff93063 avatar Mar 05 '23 18:03 jeff93063

I had that as well right now. I was using an older version because I was on an older Windows 10 build. Recently I was able to update Windows and PowerToys and now this is happening. I wasn't sure which one caused that, because the new Windows version did make a lot of stuff run slower like taking screenshots sometimes takes a couple of seconds to actually trigger and so on (it became unusable if I need a quick screenshot before stuff change on screen... but anyway, this is not the place for this report)

I've clicked on Report a bug. Where does it save it, so I can send it to you?

BTW, I've just tried deleting the file again now and it worked. The place where it didn't work was when I tried to overwrite it with a new file form the internet with same name

bergamin avatar Mar 09 '23 16:03 bergamin

I have the same issue on Windows 11, even after log out and new log on Windows. It is necessary to restart the PC to move or delete the PDF file...

nayko33 avatar Mar 15 '23 12:03 nayko33

I have the same issue. Restarting the PC fixes it, but that shouldn't be required

H-Tevin avatar Mar 29 '23 01:03 H-Tevin

For me the issue is actually with local PDF files. And in my case, File Locksmith shows dllhost.exe instead of explorer.exe as lock owner (but still COM Surrogate). I'm not 100 % sure whether my issue is due to PowerToys' preview handler, but I guess so.

Restarting the PC fixes it

You can also use File Locksmith (in the extended context menu) to end the process locking the file.

stephtr avatar Apr 12 '23 14:04 stephtr

@jaimecbernardo (since I think it's the same as #24076): I just tracked it down by looking at the processid supplied to the COM surrogate which hold the lock, it is {AB8902B4-09CA-4BB6-B78D-A8F59079A8D5}. According to the registry, that's "Thumbnail Cache Out of Proc Server"/"Thumbnail Cache Class Factory for Out of Proc Server". Is that an issue with just Windows or is it related to PowerToys thumbnail provider? Attached is also a report from just after I noticed that the file was locked.

PowerToysReport_2023-05-13-13-30-54.zip

stephtr avatar May 14 '23 16:05 stephtr

"You can also use File Locksmith (in the extended context menu) to end the process locking the file."

Not working for me. File Locksmith isn't finding anything, even when run as administrator. I cannot delete the pdf until I close the preview pane and restart my computer. image

nathanrboyer avatar May 24 '23 20:05 nathanrboyer

"You can also use File Locksmith (in the extended context menu) to end the process locking the file."

Not working for me. File Locksmith isn't finding anything, even when run as administrator. I cannot delete the pdf until I close the preview pane and restart my computer. image

Same here. Locksmith is showing nothing but deactivating preview in powertoys seems to work. I had to deactivate the file explorer add ons (untick pdf 2x) and the preview.

UsefulVid avatar Jun 20 '23 13:06 UsefulVid

Hello, I can confirm this is a real issue. I have had this issue for several months ever since I installed PowerShell. I noticed it was only on PDF files. I thought it was Acrobat forever, then decided to turn of thumbnail and preview pane options for PDF in PowerToys. My problem disappeared immediately.

+1 for getting this fixed. Right now I have to use File Locksmith every time I create a new PDF and delete it. It ends up creating dozens of dllhost.exe processes.

asheroto avatar Jun 28 '23 17:06 asheroto

Same here, but not just PDF, also SVG previews have a tendency to cause this.

rubenprins avatar Jun 28 '23 20:06 rubenprins

Same here still, with SVG files, Win 10 22H2 (though have not yet installed latest 2023-09 KB5030211 cumulative update).

I can see the dllhost {AB8902B4-09CA-4BB6-B78D-A8F59079A8D5} process holding onto handles for every SVG file I've previewed in Explorer since OS startup (eg. using Process Explorer). Must kill the dllhost proc to unlock files.

Interestingly, some programs can still write to/over these files, but others can't.

mpaperno avatar Oct 02 '23 13:10 mpaperno

This issue has been open since Jan 21, is this on the PowerToys team radar at all?

Seems like there are things being released that are lower priority than this, maybe there's a reason? 😊

asheroto avatar Oct 31 '23 19:10 asheroto

Does this only happen with PowerToys preview handlers or also other handlers too? I suspect that it's a Windows problem, because the files are locked by File Explorer and not by any of the preview handlers.

Aaron-Junker avatar Nov 02 '23 23:11 Aaron-Junker

Findings

  • The issue with PDF/SVG
  • It only happens when the PowerToys File Explorer PDF/SVG options are enabled
  • If you disable these options and restart the computer, the issue no longer happens
  • Have not confirmed if other file types are affected
  • The issue seems to occur with both preview pane and thumbnail
  • Files are locked by dllhost.exe as mentioned here
  • If you kill the dllhost.exe process, the file locking issue goes away
  • The location of the file does not change its behavior
  • PDF file security does not make a difference - the issue occurs with or without a PDF password set

Screenshots

The message COM Surrogate that the original poster mentioned seems to be related to the Thumbnail Icon generation: image

The Preview Pane seems to be related to this message:

image

Workaround

About once a day I end up doing this: image

Once I do that, I can then delete the PDF files.

Steps to replicate issue in PowerToys

  1. Enable the PDF options in PowerToys, restart the computer.
  2. Open File Explorer, enable the Preview Pane, switch View to Large Icons.
  3. Open Task Manager, click the Details tab.
  4. Now download or copy a few PDF files into the Downloads folder. Click on a few.
  5. As soon as the file downloads, open the Downloads folder.
  6. You should see dllhost.exe process start.
  7. Attempt to delete the PDF files. While some files seem to be able to be deleted, others do not delete as expected and the dllhost.exe process remains. At this point you should see one of the error messages that the file is locked.
  8. End the dllhost.exe processes then try to delete the files. You will see that the files can now be deleted.

If for some reason you don't experience the issue, try random PDF files from different sources. It doesn't necessarily happen on the same PDF files each time.

The same issue happens with SVG files, although since I use PDF files more often that's the one I've seen the issue with the most. Have not tested other supported file types.

My guess is that the dllhost.exe file is not reading or releasing the file lock correctly.

Disabling to confirm it is a PowerToys issue

  1. Disable the PDF options in PowerToys, restart the computer
  2. Open the same folder in File Explorer and attempt to delete the PDF files. You should find that the files delete as expected.

Continued troubleshooting

If someone knows the file path for the preview/icon handler log file, maybe that would be a good next step for troubleshooting.

asheroto avatar Nov 03 '23 03:11 asheroto

To respond to Aaron Junker's question: As far as I can tell, this issue happens only with the PowerToys preview handlers and of those only with the PDF (and as identified by others in the thread) SVG handlers. With those turned off, I have never experienced the issue with any other preview handlers, including other PDF handlers.

Gene


Gen-CA avatar Nov 03 '23 20:11 Gen-CA

Well the SVG previewer uses a WebView component (basically a whole web browser instance) to convert each individual SVG to a BMP (which at least explains why it's so pathetically slow). I can easily imagine some issues with that which ends up with an open handle to the original file.

The PDF one uses a PDF .NET module for the conversion, which I know nothing about. But again whatever is going on inside that module could be keeping a handle open.

I didn't look at the other preview handlers but whatever they use to do their thing must not have this issue.

This is the previewpane module.

mpaperno avatar Nov 03 '23 20:11 mpaperno

I'm also still having this issue almost daily working with PDF's. Hope this can be fixed in the near future.

Xuntar avatar Dec 13 '23 10:12 Xuntar

I've tried to reproduce the issue on 2 machines- unsuccessfully. On the first machine there was a fixed amount of running dllhost.exe examples, on the other machine on every pdf/svg file selection there were 2 new instances for a short time. But file deletion worked on both machines. It would be great if you could provide some more information. For example if you disable pdf/svg preview in PT do you still have a preview? (Maybe there is an interference between different previewers?) Or if you have some other sw related? Any help would be welcome. It seems that the issue doesn't occur all the time, there must be some additional condition. Thanks /needinfo

donlaci avatar Feb 15 '24 12:02 donlaci

Thanks for looking into this issue. I've had the issue ever since the feature was available but didn't chime in until later on when it hadn't been fixed yet. 😊

Baseline: If PDF/SVG preview is disabled, and in Windows Explorer the view is set on "Large icons", a thumbnail is not shown.

You are correct in that the issue does not happen all of the time, although today I was able to replicate the issue immediately. The same issue occurs on other computers I have as well, so I'm positive it's not specific to one computer.

Running Process Hacker, while searching for dllhost, I see no processes. With Windows Explorer visible, using the same folder as mentioned above, toggling "Portable Document Format" to the "on" position results in dllhost.exe launching. and remaining launched. No preview is shown so far.

image

Closing Windows Explorer does not end the process. Opening a new instance of Windows Explorer, the same process is still running, but now a new dllhost.exe has appeared. Closing the window usually makes the latest dllhost.exe disappear, but not always. This is why it's hard to troubleshoot. I have not found a pattern to this.

At first I thought it might be the because of the PDF version of the file. Like maybe PDF versions > 9.0 were causing the issue, and not versions less than that. However this is not the case, as far as I can tell. Password/security does not make a difference either. My gut feeling is that the thumbnail generation process encounters some issue when processing a PDF, and instead terminating the dllhost.exe process, it messes up and is stuck in memory. Improving error handling when processing thumbnails may be the fix.

Opening a folder with several PDFs in it causes many dllhost.exe processes to start. Closing Windows Explorer does not end these processes. Also noticed that dllhost.exe will start when right-clicking a PDF file.

image

Attached are logs in a zip file. Some interesting lines from the logs that might be relevant:

[2024-02-19 16:07:06.692575] [p-17940] [t-16740] [info] isApplied of HKCU\Software\Classes\CLSID\{FCDD4EED-41AA-492F-8A84-31A1546226E0}\DisplayName:Svg Preview Handler: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-02-19 16:07:06.698018] [p-17940] [t-16740] [info] isApplied of HKCU\Software\Classes\CLSID\{A5A41CC7-02CB-41D4-8C9B-9087040D6098}\DisplayName:Pdf Preview Handler: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-02-19 16:07:06.699462] [p-17940] [t-16740] [info] isApplied of HKCU\Software\Classes\CLSID\{10144713-1526-46C9-88DA-1FB52807A9FF}\DisplayName:Svg Thumbnail Provider: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-02-19 16:07:06.699808] [p-17940] [t-16740] [info] isApplied of HKCU\Software\Classes\CLSID\{D8BB9942-93BD-412D-87E4-33FAB214DC1A}\DisplayName:Pdf Thumbnail Provider: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-02-19 16:07:06.709001] [p-17940] [t-16740] [info] isApplied of HKCU\Software\Classes\CLSID\{FCDD4EED-41AA-492F-8A84-31A1546226E0}\DisplayName:Svg Preview Handler: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-02-19 16:07:06.715633] [p-17940] [t-16740] [info] isApplied of HKCU\Software\Classes\CLSID\{10144713-1526-46C9-88DA-1FB52807A9FF}\DisplayName:Svg Thumbnail Provider: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-02-19 16:07:06.715705] [p-17940] [t-16740] [info] isApplied of HKCU\Software\Classes\CLSID\{D8BB9942-93BD-412D-87E4-33FAB214DC1A}\DisplayName:Pdf Thumbnail Provider: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-01-31 12:20:48.188095] [p-43812] [t-23480] [info] isApplied of HKCU\Software\Classes\CLSID\{A5A41CC7-02CB-41D4-8C9B-9087040D6098}\DisplayName:Pdf Preview Handler: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-01-31 12:20:48.188820] [p-43812] [t-23480] [error] unApply of HKCU\Software\Classes\CLSID\{10144713-1526-46C9-88DA-1FB52807A9FF}\InprocServer32\Default:C:\Program Files\PowerToys\PowerToys.SvgThumbnailProviderCpp.dll: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-01-31 12:20:48.189435] [p-43812] [t-23480] [error] unApply of HKCU\Software\Classes\CLSID\{10144713-1526-46C9-88DA-1FB52807A9FF}\InprocServer32\Assembly:PowerToys.SvgThumbnailProvider, Version=v0.78.0.0, Culture=neutral: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-01-31 12:20:48.189458] [p-43812] [t-23480] [error] unApply of HKCU\Software\Classes\CLSID\{10144713-1526-46C9-88DA-1FB52807A9FF}\InprocServer32\Class:SvgThumbnailProvider: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-01-31 12:20:48.189474] [p-43812] [t-23480] [error] unApply of HKCU\Software\Classes\CLSID\{10144713-1526-46C9-88DA-1FB52807A9FF}\InprocServer32\ThreadingModel:Apartment: RegOpenKeyExW failed: The system cannot find the file specified.
[2024-01-31 12:20:48.190251] [p-43812] [t-23480] [error] Couldn't disable file explorer module svg-thumbnail-toggle-setting during apply_settings
[2024-01-31 12:20:48.190317] [p-43812] [t-23480] [info] isApplied of HKCU\Software\Classes\CLSID\{D8BB9942-93BD-412D-87E4-33FAB214DC1A}\DisplayName:Pdf Thumbnail Provider: RegOpenKeyExW failed: The system cannot find the file specified.

File_Explorer_Logs.zip

The only other thing I can think of to mention is that I do use Adobe Acrobat Pro, continuous release. Thumbnails are not generated through Acrobat, so I don't think this affects the issue, but thought I'd mention it just in case. When the issue occurs, no Adobe processes are running.

If there is some way to enable additional debugging for File Explorer Add-ons, I'm willing to turn that on so we can help fix this issue.


Workaround - ending dllhost.exe process quickly

As a temporary workaround, I simply created a file called dll.cmd and have this:

taskkill /f /im dllhost*

I then placed that file in system32 so I could simply press Win+R, type dll, and press enter, to end the processes.

asheroto avatar Feb 19 '24 23:02 asheroto

@asheroto Hi, The info you provided was helpful, thanks a lot. I suspect there is something gone wrong on initialization of the svg/pdf previewers. The error message (which in some cases repeats 700++ times in 4 seconds) says that the preview handlers are not found. Could you please provide the following information: Do you have a machine or user setup of the PT? Could you please check that the following files are present in your PT installed directory (c:\Program Files\PowerToys\ or similar): PowerToys.SvgPreviewHandlerCpp.dll PowerToys.SvgThumbnailProviderCpp.dll PowerToys.PdfPreviewHandlerCpp.dll PowerToys.PdfThumbnailProviderCpp.dll

Thank you very much!

/needInfo

donlaci avatar Feb 21 '24 09:02 donlaci

Machine setup, PowerToys is located in C:\Program Files\PowerToys.

Indeed, the files are present.

image

asheroto avatar Feb 22 '24 05:02 asheroto

Although I started this issue thread so presumably am the person from whom "author feedback" is required, [asheroto] has been providing more technical details than I would be able to. So my feedback as the author is that the issue is ongoing, the thread is not stale, and this should not be closed as inactive.

Gen-CA avatar Feb 29 '24 20:02 Gen-CA

This has been worked on during the 0.80 release cycle. Please update to the latest release: https://github.com/microsoft/PowerToys/releases

jaimecbernardo avatar Apr 08 '24 21:04 jaimecbernardo