问题在执行一个exe当路径中有空格。 [英] Issue executing an exe when the path has spaces.

查看:126
本文介绍了问题在执行一个exe当路径中有空格。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本作品:

SET server=MyServer
SET db=MyDb 

FOR /F "usebackq tokens=1" %%i IN (`sqlcmd -S %server% -d %db% -w200 -h-1 -E -Q "set nocount on; select REPORTING_DATE FROM dbo.CURRENT_REPORTING_DATE"`) DO set REPORTING_DATE=%%i 
ECHO The Reporting Date is %REPORTING_DATE%

但是,当我尝试的路径完全有资格SQLCMD ...

But when I try to fully qualify the path to sqlcmd...

SET sqlcmdexe="C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" SET server=MyServer SET db=MyDb 

FOR /F "usebackq tokens=1" %%i IN (` %sqlcmdexe% -S %server% -d %db%
-w200 -h-1 -E -Q "set nocount on; select REPORTING_DATE FROM dbo.CURRENT_REPORTING_DATE"`) DO set REPORTING_DATE=%%i  ECHO The Reporting Date is %REPORTING_DATE%

我得到的错误:

系统找不到指定的路径。

The system cannot find the path specified.

... presumably因为文件夹名称空间。

...presumably because of the spaces in the folder name.

我要如何改变路径,以波浪线路径(W / O空间),或者更好的是,它的报价让这个语句的执行是否正确?

How do I change the path to a tilde path (w/o spaces) or better yet, quote it so that this statement executes properly?

请注意,有之前%sqlcmdexe%向后抽动,不知道为什么我没有看到它,至少在IE6。是的,6!

Note that there is a backwards tic before %sqlcmdexe% , not sure why I don't see it, at least in IE6. Yes, 6!

推荐答案

如何改变路径,以波浪线路径(W / O空间)

由于我没有sqlcmd.exe安装呢,我用一个不同的例子。例如,见这样的:

As I don't have sqlcmd.exe installed, I use a different example. See for example this:

@echo off
set sqlcmdexe=C:\Program Files\Internet Explorer\Connection Wizard\icwconn2.exe
echo %sqlcmdexe%

for /f "tokens=*" %%a in ("%sqlcmdexe%") do set sqlcmdexe=%%~sa
echo %sqlcmdexe%

我的系统上运行,输出是:

Run on my system, the output is:

C:\temp>envtest
C:\Program Files\Internet Explorer\Connection Wizard\icwconn2.exe
C:\PROGRA~1\INTERN~1\CONNEC~1\icwconn2.exe

但我不知道是否能解决您的问题。

But I don't know if this solves your problem.

这篇关于问题在执行一个exe当路径中有空格。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆