【发布时间】:2014-06-06 16:10:37
【问题描述】:
我想使用 VBA 或 PowerShell 来杀死当前被锁定的文件(因为另一个用户打开了它)。
即使我没有管理员权限,有没有办法做到这一点?有没有 1337 黑客可以帮助我?
这是 VBA 中的基本设置,但现在我在尝试终止打开的文件时收到 permission denied 错误。
Function fn_testKILL()
'load INI data
fn_ReadINI
'read files from iDumpFolder
Dim fs As Object
Set fs = CreateObject("Scripting.FileSystemObject")
Dim objFolder As Object
Set objFolder = fs.GetFolder(iDumpFolder)
Dim objFile As Object
For Each objFile In objFolder.files
' is the file open? if yes, kill file.
If Not FileLocked(objFolder & "\" & objFile.Name) Then
'file is locked
'do nothing
Else
'file is locked
Kill objFile
'or if this is not possible with VBA, trigger PS1 execution
End If
Next 'objFile
'Cleanup
Set objFolder = Nothing
Set objFile = Nothing
Set fs = Nothing
End Function
【问题讨论】:
标签: vba ms-access powershell ms-office