【发布时间】:2011-09-22 05:09:00
【问题描述】:
我有以下 PowerShell 脚本来验证我的 SVN 存储库:
$SVNAdminDir = 'C:\Program Files (x86)\VisualSVN Server\bin';
$RepositoryDir = 'C:\My Repositories\App1';
$_cmd = "`"$SVNAdminDir`\svnadmin`" verify `"$RepositoryDir`"";
Write-Host $_cmd; # Copying this into the command prompt runs without an issue...
cmd.exe /c $_cmd; # It's when I try to execute the command from PS that I get the error.
但是当我尝试执行它时,我收到以下错误消息:
cmd.exe : 'C:\Program' is not recognized as an internal or external command,
At line:5 char:12
+ cmd.exe <<<< /c $_cmd;
+ CategoryInfo : NotSpecified: ('C:\Program' is...ternal command,:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
operable program or batch file.
由于我实际上是在单引号内使用双引号设置 $cmd = '"C:\Program Files (x86)\VisualSVN Server\bin\svnadmin" verify "C:\My Repositories\App1"';,因此我期望 C:\Program Files (x86)\... 中的空格被传递正确。
我怀疑我缺少的字符串有些微不足道...
【问题讨论】:
标签: svn powershell cmd visualsvn-server