首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell在后台打开hta

Powershell在后台打开hta
EN

Stack Overflow用户
提问于 2013-01-16 01:46:57
回答 1查看 626关注 0票数 0

我正在做一个项目,没有足够的时间来重写用HTA写的东西。我需要使用cmd.exe /C调用一个HTA (这样它就会在公式制定后关闭窗口,生成一个闪烁的hta框)。我可以用调用表达式的方式来做这件事,但是我想把它作为一个混合变量的start-job来做。

代码语言:javascript
复制
$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查看完整的变量。

看起来很简单,而且可能是可以毫不费力地工作的。

有什么想法吗?

EN

回答 1

Stack Overflow用户

发布于 2013-01-16 02:02:00

请尝试使用双引号将命令括起来

代码语言:javascript
复制
Invoke-Expression -command "cmd /c $FP /H:`"$output`""
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14343651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档