VBS 脚本运行无权限错误:解决方法
该 VBS 脚本需要在具有足够权限的计算机上运行。如果您收到 '无权限' 错误提示,可能是因为您没有足够的权限来访问所需的文件夹或文件。请确保以管理员身份运行该脚本或者联系计算机管理员以获取适当的权限。
On Error Resume Next '跳过错误 ' 设置路径和文件名 a=createobject("Scripting.FileSystemObject").GetFolder(".").Path AAA=inputbox("填写文件位置:") A1 = a & "\文件1.txt" A2 = a & "\文件2.txt"
' 创建文件夹列表.txt和文件列表.txt Set objFSO = CreateObject("Scripting.FileSystemObject") Set objOutFolder = objFSO.CreateTextFile(A1, True) Set objOutFile = objFSO.CreateTextFile(A2, True) ' 遍历文件夹A Set objFolder = objFSO.GetFolder(AAA) ListFolder objFolder
Sub ListFolder(objFolder) ' 输出文件夹名到文件夹列表.txt objOutFolder.WriteLine(objFolder.Path)
' 遍历文件夹中的文件
For Each objFile In objFolder.Files
' 输出文件名到文件列表.txt
objOutFile.WriteLine(objFile.Path)
Next
' 递归遍历子文件夹
For Each objSubFolder In objFolder.SubFolders
ListFolder objSubFolder
Next
End Sub
' 关闭文件 objOutFolder.Close objOutFile.Close
原文地址: https://www.cveoy.top/t/topic/bQ2k 著作权归作者所有。请勿转载和采集!