简体   繁体   English

如何使用 robocopy 运行目录名称中有空格的 PowerShell 提升副本?

[英]How do I use robocopy to run a powershell elevated copy with spaces in the directory names?

If you find a better question that encompasses my situation, please let me know.如果您发现更适合我的情况的问题,请告诉我。 I haven't found my case yet.我的case还没找到

I tried running an elevated powershell command with:我尝试使用以下命令运行提升的 powershell 命令:

powershell -command "somecommand -Verb runas"

as作为

powershell -command "robocopy \\hostess\blab\foo 'C:\Program Files\foo ' /s /e /r:0 /z -Verb runas"

The robocopy part works by itself but then adding powershell causes: robocopy 部分自行工作,但随后添加了 powershell 原因:

ERROR : Invalid Parameter #7 : "-Verb"

The verb is a parameter of powershell executable and not part of the command parameter动词是 powershell 可执行文件的参数,而不是命令参数的一部分

powershell -command "robocopy \\hostess\blab\foo 'C:\Program Files\foo ' /s /e /r:0 /z" -Verb runas

see also https://ss64.com/ps/syntax-elevate.html另见https://ss64.com/ps/syntax-elevate.html

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

相关问题 如何使用robocopy在Powershell脚本中仅复制目录的文件夹内容 - How to copy **only** the folder content of a directory in powershell script with robocopy 如何在Powershell中仅使用robocopy复制文件夹? - How can i only copy folders with robocopy in powershell? 我如何在脚本中使用提升的凭据运行 powershell,然后在其位置执行文件 - How do i Run powershell with elevated credential in the script then execute files in their locations 如何将带空格的参数作为数组传递给Powershell中的RoboCopy? - How to pass parameters with spaces as an array to RoboCopy in Powershell? 如何从提升的批处理文件运行Powershell以使用当前用户? - How to run powershell from an elevated batch file to use current user? 如何在 Windows Powershell 中修复此 Robocopy 错误? - How do I fix this Robocopy error in Windows Powershell? 如何在Powershell中更改目录并在该目录中运行文件? - How do I change directory and run a file in that directory in powershell? 具有目录列表的Powershell中的Robocopy - Robocopy in Powershell with directory list 使用PowerShell调整RoboCopy目录大小 - RoboCopy Directory Sizing with PowerShell 如何使用PowerShell在cmd [elevated]中运行命令? - How to run commands in cmd [elevated] using PowerShell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM