【发布时间】:2017-12-11 02:59:05
【问题描述】:
我创建了一个脚本,它从 DropBox 复制我们的工作 PowerPoint 演示文稿模板并将其保存为默认模板。
有些用户帐户有空格,有些则没有,而且我无法获取用于触发此脚本运行的批处理文件。
我已经尝试了我能想到的所有类型的格式 {}""'' 等
"'%UserProfile%'\'Dropbox'\'Group Team Folder'\'Templates'\'PowerPoint Template.potx'"
预期结果是批处理文件使用用户名“John Smith”中的空白作为 PowerPoint 模板路径的一部分,而不是将其截断。
它吐出一个错误,说明路径“C:\Users\John”无法识别。
任何帮助将不胜感激
编辑
@ECHO OFF
If exist "%UserProfile%\Dropbox\Group Team Folder\Templates\PowerPoint Template.potx" (
PowerShell.exe -ExecutionPolicy Bypass -Command "%UserProfile%\Dropbox\Group Team Folder\Templates\Script\Powerpoint Template.ps1"
)
If exist "%UserProfile%\Dropbox (Group)\Group Team Folder\Templates\PowerPoint Template.potx" (
PowerShell.exe -ExecutionPolicy Bypass -Command "%UserProfile%\Dropbox\Group Team Folder\Templates\Script\Powerpoint Template.ps1"
)
PAUSE
如果没有单个刻度,它不适用于具有没有空格的用户配置文件的系统。 请注意重复代码的原因是因为在某些系统上 Dropbox 有 2 个不同的目录,因此它使用 PowerPoint 模板来确定路径是否适合该系统。
编辑 2
C:\Users\John\Dropbox\Group : The term 'C:\Users\John\Dropbox\Group' is not
recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ C:\Users\John\Dropbox\Group Team Folder\Templates\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
那是我的命令提示符错误。
我不知道为什么这不起作用。
【问题讨论】:
-
您需要向我们展示您在其中使用的命令。并删除单引号。
-
去掉所有的单引号,留下周围的双引号。
-
删除单个刻度会阻止脚本在没有空格以及包含空格的系统上运行
-
当涉及到批处理文件中包含空格的任何内容时,我们会为您提供一个简单明了的事实。用双引号括起来。在您向我们展示所有脚本之前,我们无法帮助您。
-
我更新了整个脚本,我希望这是删除单个刻度的问题-_-
标签: powershell batch-file path