为什么在具有管理员权限的情况下将文件夹移动到程序文件文件夹时拒绝访问? [英] Why is access denied on moving a folder to program files folder with administrator privileges?

查看:243
本文介绍了为什么在具有管理员权限的情况下将文件夹移动到程序文件文件夹时拒绝访问?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我想将一个名为test的文件夹移动到目录"%PROGRAMFILES(x86)%". 但是,即使以管理员身份运行批处理文件,它也不会真正移动.我收到错误消息:

So I want to move a folder called test to the directory "%PROGRAMFILES(x86)%". However, even by running the batch file as administrator, it won't really move. I get the error message:

访问被拒绝.

Access denied.

这是我当前的批处理文件:

This is my current batch file:

@echo off
move %~dp0test "%PROGRAMFILES(x86)%"
pause

%~dp0用于文件夹的当前目录(在我的情况下为桌面).

%~dp0 is for the current directory of the folder (desktop in my case).

那么我该如何解决此问题,将文件夹test移至"%PROGRAMFILES(x86)%"而不会出现拒绝访问错误?

So how can I solve this issue to move the folder test to "%PROGRAMFILES(x86)%" without the access denied error?

推荐答案

在您的情况下,使用已经具有管理员权限的批处理文件来运行时,可能会导致访问被拒绝的错误消息

The access denied error message could be caused in your case with running the batch file already with administrator privileges by

  • 应用程序当前正在打开的目录中要移动的文件,或者
  • 要移动的目录是正在运行的进程的当前目录(批处理文件),或者
  • 管理员帐户对您的桌面文件夹没有权限,这是不太可能的,但有可能,因为它是用户配置文件中的文件夹,而不是管理员帐户的用户配置文件中的文件夹.

在前两种情况下,无法删除指定的目录,并且结果是共享访问被拒绝错误消息.因此,不是目标文件夹中的权限可能是这里的问题,而是源文件夹及其文件的共享访问权限.

In the first two cases it is not possible to delete the specified directory and a sharing access denied error message is the result. So not the permissions in target folder are perhaps the problem here, but the sharing access permissions on source folder and their files.

顺便说一句:最好使用move "%~dp0test" "%ProgramFiles(x86)%"作为批处理文件的路径,因为即使批处理文件位于Windows Vista或更高版本上的Windows桌面文件夹中(当前不是这种情况)也可以包含一个空格,只要您的用户名可以不包含空格字符.

By the way: Better use move "%~dp0test" "%ProgramFiles(x86)%" as path of batch file could contain a space even if this is not the case currently with batch file being in your Windows desktop folder on Windows Vista or later as long as your user name does not contain a space character.

这篇关于为什么在具有管理员权限的情况下将文件夹移动到程序文件文件夹时拒绝访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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