小编via*_*via的帖子

cmd中哪个符号是转义符?

我有这个代码:

powershell -command "& { (New-Object Net.WebClient).DownloadFile('linkToMyFile.file', 'C:\my.file') }"
Run Code Online (Sandbox Code Playgroud)

它用于下载文件。
当我在远程服务器上的 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') }""
Run Code Online (Sandbox Code Playgroud)

我尝试使用^符号,但同样的错误;
使用 ^ 符号作为双引号的代码:

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') }^""
Run Code Online (Sandbox Code Playgroud)

另外,我尝试使用\(就像在 PHP 中一样)进行转义,但得到了相同的结果。
帮助解决此问题或提供如何使用命令行远程下载文件的建议。

powershell command-line cmd

4
推荐指数
1
解决办法
4万
查看次数

标签 统计

cmd ×1

command-line ×1

powershell ×1