【发布时间】:2017-02-03 21:00:07
【问题描述】:
我有这个代码:
powershell -command "& { (New-Object Net.WebClient).DownloadFile('linkToMyFile.file', 'C:\my.file') }"
用于下载文件。
当我在远程服务器上的 cmd 中执行它时 - 一切正常。
但是,当我想使用 paexec 从远程服务器上的计算机上执行此代码时,我遇到了转义字符的一些问题。
我的 CMD 中的命令:
psexec.exe \\remoteServer.0.1 -u username -p password -dbg -lo D:\PsExec.log cmd /c "powershell -command "& { (New-Object Net.WebClient).DownloadFile('linkToMyFile.file', 'C:\my.file') }""
我尝试使用^符号,但同样的错误;
使用 ^ 符号作为双引号的代码:
psexec.exe \\remoteServer.0.1 -u username -p password -dbg -lo D:\PsExec.log cmd /c "powershell -command ^"& { (New-Object Net.WebClient).DownloadFile('linkToMyFile.file', 'C:\my.file') }^""
另外,我尝试使用\(如在 PHP 中)进行转义,但结果相同。
对此提供帮助或提供建议,我如何使用命令行远程下载文件。
【问题讨论】:
-
我试过这个。不要工作。
-
反引号?还有,可以直接调用powershell,为什么还要
cmd /c呢? -
嗯,你是对的。我可以使用 powershell.exe “mycommand”。我忘记了。
标签: powershell command-line cmd