这是我遇到的问题:
@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相同的文件夹中.有什么建议?
这是我遇到的问题:
# 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路径?