小编Ric*_*ick的帖子

批处理文件:如果路径有空格,则FOR/F不起作用

这是我遇到的问题:

@ECHO OFF

REM If this batch file is run in the same directory as "command.exe" then the
REM following line will work.
FOR /F "usebackq" %%A IN (`command.exe "C:\File Being Passed as a Parameter.txt"`) DO ECHO %%A

REM The following line does not work no matter where this batch file is run.
FOR /F "usebackq" %%A IN (`"C:\Folder With Spaces\command.exe" "C:\File Being Passed as a Parameter.txt"`) DO ECHO %%A
Run Code Online (Sandbox Code Playgroud)

我想将这个批处理文件存储在任何我想要的地方,而不是强制将它存储在与command.exe相同的文件夹中.有什么建议?

batch-file

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

PowerShell:无法将数据写入包含方括号的UNC路径

这是我遇到的问题:

# The following line works
Add-Content -LiteralPath "$Env:USERPROFILE\Desktop\[Test].txt" -Value "This is a test"

# The following line does not work and does not output an error message
Add-Content -LiteralPath "\\Server\Share\[Test].txt" -Value "This is a test"
Run Code Online (Sandbox Code Playgroud)

我已经检查了我的权限,我肯定有权写入网络共享.问题只发生在我使用"LiteralPath"参数时,遗憾的是,这是我正在做的事情所必需的.

如何将数据写入包含方括号的UNC路径?

powershell unc

7
推荐指数
1
解决办法
5770
查看次数

标签 统计

batch-file ×1

powershell ×1

unc ×1