我正在做一个项目,没有足够的时间来重写用HTA写的东西。我需要使用cmd.exe /C调用一个HTA (这样它就会在公式制定后关闭窗口,生成一个闪烁的hta框)。我可以用调用表达式的方式来做这件事,但是我想把它作为一个混合变量的start-job来做。
$RunHTA = {
param(
[string]$FP, ### filepath to hta
[string]$output) ### output
Invoke-Expression -command 'cmd.exe /C $FP /H:`"$output`"' ### this line works alone. the /H is the save report feature and the double quotes are needed by the hta
}
$fp="C:\Path\To\HTA\file.hta"
$output = "C:\Output\path"
$j = Start-job $RunHTA -ArgumentList $FP,$output
$j | Receive-job
The filename, directory name, or volume label syntax is incorrect.
+ CategoryInfo : NotSpecified: (The filename, d...x is incorrect.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError我已经做了一些测试,变量可以正确传递。使用returns查看完整的变量。
看起来很简单,而且可能是可以毫不费力地工作的。
有什么想法吗?
发布于 2013-01-16 02:02:00
请尝试使用双引号将命令括起来
Invoke-Expression -command "cmd /c $FP /H:`"$output`""https://stackoverflow.com/questions/14343651
复制相似问题