gpt4 book ai didi

javascript - 批量删除%LOCALAPPDATA%中的文件夹

转载 作者:行者123 更新时间:2023-12-03 11:48:08 24 4
gpt4 key购买 nike

我需要从所有用户本地配置文件中删除特定文件夹C:\Users\{用户名}\AppData\Local\

我创建了一个简短的脚本来执行此操作,并且我必须以管理员身份运行它,因为我首先运行另一个程序。

call c:\test.exe

rd /s /q %LOCALAPPDATA%\test

问题是,这只会删除管理员的 AppData 中的文件夹,而不会删除所有其他用户的文件夹中的文件夹。

有什么方法可以批量、Powershell 或最终在 VBS 中执行此操作吗?

我的操作系统是 Windows 7 x64

最佳答案

在 PowerShell 中:

Remove-Item 'C:\Users\*\AppData\Local\test' -Recurse -Force

在 VBScript 中:

Set fso = CreateObject("Scripting.FileSystemObject")
For Each sf In fso.GetFolder("C:\Users").SubFolders
f = fso.BuildPath(sf.Path, "AppData\Local\test")
If fso.FolderExists(f) Then fso.DeleteFolder f, True
Next

批量:

for /d %d in (C:\users) do @if exists "%d\AppData\Local\test" rd /s /q "%d\AppData\Local\test"

关于javascript - 批量删除%LOCALAPPDATA%中的文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25958156/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com