简体   繁体   English

在批处理文件中以管理员身份复制文件

[英]Copying files as administrator in a batch file

So I have a batch file that copies files from one folder to a bunch of different folders. 所以我有一个批处理文件,可以将文件从一个文件夹复制到一堆不同的文件夹中。

The purpose of this batch file is to be like a simple installer(Without registry edits) to make it easier for others to use a set of files I am distributing. 这个批处理文件的目的就像一个简单的安装程序(没有注册表编辑),以便其他人更容易使用我正在分发的一组文件。 Because this is being widely distributed, it will need to work on windows operatings systems from XP on. 因为这是广泛分布的,所以它需要在XP上运行Windows操作系统。 The files need to be moved to the program files of a program (This works), their documents folder(Also works), and the program folder in the all users start menu(Does not work). 这些文件需要移动到程序的程序文件(这个工作),它们的文件夹(也可以工作),以及所有用户开始菜单中的程序文​​件夹(不起作用)。

So far I have been unsuccessful with xcopy and robocopy as they both tell me "access denied". 到目前为止,我一直没有成功使用xcopy和robocopy,因为他们都告诉我“访问被拒绝”。 Also running the batch file with "Run as administrator". 还使用“以管理员身份运行”运行批处理文件。 If you can think of a more effective way to do what I'm trying to do besides a batch file I am open to ideas. 如果你能想到一个更有效的方法来做我正在尝试做的事情,除了批处理文件,我愿意接受想法。

xcopy /q /y ".\add_ui.bat" "%PROGRAMDATA%\Microsoft\Windows\Start Menu\Programs\My Program\Add.bat"

I'm sure there's some simple trick that I'm missing. 我确信有一些我想念的简单技巧。

Thanks in advance! 提前致谢!

您必须具有本地管理员权限才能写入该文件夹,并且您的批处理文件需要使用提升的权限运行运行方式管理员 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM