Windows Server 2012 VBScript获取拒绝删除文件的权限 [英] Windows Server 2012 VBScript gets permission denied deleting files

查看:536
本文介绍了Windows Server 2012 VBScript获取拒绝删除文件的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在服务器(Windows Server 2012 r2)上有一个与所有人共享的文件夹.我所有的用户每天都上传纯文本清单文件.然后,我有一个计划在我的管理员凭据下运行的vbscript,该vbscript在读取这些文件后将其删除.但是,尝试删除或移动文件时出现权限被拒绝错误.

I have a folder on my server (Windows Server 2012 r2) that is shared with Everyone. All my users upload a plain text inventory file each day. I then have a vbscript that I scheduled to run under my Administrator credentials which deletes these files after reading them. However, I get permission denied errors when trying to delete or move the files.

以下是一些失败的简单代码:

Here is some simple code that fails:

Dim PathtoInventoryFiles
Dim myFSO
Dim myFile
Dim colFiles

PathtoInventoryFiles = "D:\Inventory$"
Set myFSO = CreateObject("Scripting.FileSystemObject")
Set colFiles = myFSO.GetFolder(PathtoInventoryFiles).Files

For Each myFile In colFiles
    wscript.echo myFile.path
    'Tried both of the following (only one at a time of course)
    myFSO.DeleteFile myFile.Path 'Permission denied
    myFile.Delete 'Permission denied
Next

Set myFSO = Nothing
Set colFiles = Nothing

回声会生成指向正确和现有文件的正确路径.所以我认为我有权限问题?这是Server 2012的普通安装.

The echo produces a correct path to a good and existing file. So I'm thinking I have a permissions issue? This is a pretty plain vanilla installation of Server 2012.

推荐答案

在权限已允许访问的文件上获取权限被拒绝"错误通常意味着该文件(仍)由某人/某物打开.您可以使用net file检查是否进行了远程连接,或者使用 handle 用于本地流程.

Getting a "permission denied" error on a file where the permissions already allow access usually means that the file is (still) opened by someone/something. You can check that with net file for remote connections, or handle for local processes.

这篇关于Windows Server 2012 VBScript获取拒绝删除文件的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆