简体   繁体   中英

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.

I tried running an elevated powershell command with:

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:

ERROR : Invalid Parameter #7 : "-Verb"

The verb is a parameter of powershell executable and not part of the command parameter

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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