调用表达式-命令即使存在也找不到文件 [英] Invoke-Expression -Command Not Finding File Even Though It Exists

查看:70
本文介绍了调用表达式-命令即使存在也找不到文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部

我正在尝试在Power Shell中运行命令,但被告知该文件不存在,因为它现在代表Power Shell代码.如果我在DOS中执行相同的操作,它将找到该文件并正确执行.唯一的区别是文件名周围有一个附加的打开和关闭双引号.可以在Power Shell中以相同的方式完成此操作吗?如果是这样,怎么办,因为我对Power Shell不熟悉.

I am trying to run a command in Power Shell and I am told the file does not exist as it stands right now for the Power Shell code. If I do the same in DOS, it finds the file and executes correctly. The only difference is that there is an additional open and closed double quote around the file name. Can this be done in Power Shell the same way? If so, how can this be done as I am not familiar with Power Shell.

DOS:

IF EXISTS F:\lvcecstos.CSV F:\LaserVault\ContentExpress\ContentExpress.exe /CID:1 /CSV:<b>"F:\lvcecstos.CSV"</b> /ClearSubscription

电源外壳:

Invoke-Expression -Command "F:\LaserVault\ContentExpress\ContentExpress.exe /CID:1 /CSV:<b>F:\lvcecstos.csv</b> /ClearSubscription"

在此先感谢您提出任何建议.创建该软件包的Laservault工程师告诉我,我们使用文件名前后的双引号是必需的.对于我来说为什么没有意义,但这是我无法解决的.

Thanks in advance for any suggestions. I am told by the Laservault engineers that created this software package that we use that the double quotes around the file name is required. Doesn't make sense to me as to why though, but this is something I am unable to get around.

推荐答案

如果具有PowerShell v3(应使用),则可以使用魔术参数" --%(请参阅

If you have PowerShell v3 (which you should) you could use the "magic parameter" --% (see here).

& F:\LaserVault\ContentExpress\ContentExpress.exe --% /CID:1 /CSV:"F:\lvcecstos.csv" /ClearSubscription

否则,尝试在参数周围保留双引号可能会非常痛苦.例如,请参见有关类似问题的答案.

Otherwise trying to preserve double quotes around arguments could become very, very painful. See for instance this answer to a similar question.

这篇关于调用表达式-命令即使存在也找不到文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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