【问题标题】:Using .bat to launch a powershell script使用 .bat 启动 powershell 脚本
【发布时间】:2012-06-08 12:21:33
【问题描述】:
我可以在 powershell 中成功执行以下脚本,但是当我尝试从 .bat 运行脚本时,我不成功。.bat 文件是否以某种方式调用 powershell 脚本,因为它一直失败。
我将如何创建一个 .bat 脚本来运行下面的 powershell 脚本。
cd 'Program Files (x86)\Citrix \XenApp \ServerConfig' .\XenAppConfigConsole.exe /ExecutionMode:Join /FarmName:xencity /OdbcUsername:chris /odbcPassword:Jahner0 /DsnFile:"C:\xencitylifeSQLDS.dsn"
请大家帮忙
非常感谢
【问题讨论】:
标签:
batch-file
powershell-3.0
【解决方案1】:
您可以通过将powershell 放在命令开头来做到这一点
powershell cd 'Program Files (x86)\Citrix \XenApp \ServerConfig' .\XenAppConfigConsole.exe /ExecutionMode:Join /FarmName:xencity /OdbcUsername:chris /odbcPassword:Jahner0 /DsnFile:"C:\xencitylifeSQLDS.dsn"
这只是调用 powershell 并给它你的运行命令,除了你在 cmd 中运行它。