删除项目后强制桌面上的图标刷新,或者首先停止添加项目(Force the icons on the desktop to refresh after deleting items, or stop a

编程入门 行业动态 更新时间:2024-10-28 14:29:06
删除项目后强制桌面上的图标刷新,或者首先停止添加项目(Force the icons on the desktop to refresh after deleting items, or stop an item from being added in the first place)

我创建了一个powershell脚本,用于侦听要在桌面上创建的文件。 如果符合特定条件,该文件将被立即删除。 我使用了Remove-Item $path ,其中$path是我想要删除的文件的路径。 问题是窗口仍然增加,并继续在桌面上显示该项目。 该文件绝对不存在,因为试图操作它将导致“无法找到此项目”或“文件不存在”错误。 通过“右键点击=>刷新”手动刷新桌面将导致项目被删除。

删除桌面上的项目后,是否有办法强制桌面刷新? 否则,是否有替代方法来删除文件以防止它被添加到第一个地方?

I have created a powershell script that listens for files to be created on the desktop. The file is immediately deleted if it meets certain criteria. I used Remove-Item $path where $path is the path to the file I want to delete. The problem is that windows still adds, and continues to show the item on the desktop. The file is definitely not there, since attempting to manipulate it will result in a 'Could not find this item', or 'File does not exist' error. Manually refreshing the desktop via 'Right Click => Refresh' will cause the item to be removed.

Is there a way to force the desktop to refresh after deleting an item on it? Otherwise, is there an alternate method to delete the file to prevent it being added in the first place?

最满意答案

您可以使用Shell32.dll中的SHChangeNotify

你在PowerShell.com中有一个函数

ou can use the SHChangeNotify from Shell32.dll

You've got a function in PowerShell.com

更多推荐

本文发布于:2023-08-07 02:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1459521.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   图标   桌面上   icons   desktop

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!