我有一个很长的powershell脚本,需要从python脚本执行。 当我从命令行运行powershell脚本时,它工作得很好,但当我从python运行它时,它会失败。在
我已经将powershell脚本简化为以下代码,这将重现该问题。在
Powershell脚本:
import-module WebAdministration
Add-Type -Path C:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll
Set-WebConfigurationProperty '/system.webServer/proxy' -Name "enabled" -Value "true"
Python脚本:
^{pr2}$当我从运行powershell脚本时命令提示符,它工作良好,不产生输出。 当我运行python脚本时,它会产生以下错误:
Set-WebConfigurationProperty : Retrieving the COM class factory for component
with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following
error: 80040154
Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
At [pathToMyPowershellScript]:3 char:1
+ Set-WebConfigurationProperty '/system.webServer/proxy' -Name "enabled" -Value "t ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo
: NotSpecified: (:) [Set-WebConfigurationProperty], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,
Microsoft.IIs.PowerShell.Provider.SetConfigurationPropertyCommand
我在Windows7Professional(x64)上运行iis7.5,使用python2.7和Powershell 1.0 有什么想法吗?在
您的程序可能调用了错误版本的powershell,请尝试显式调用exe。在
Heres some related reading you might find interesting.
我可以通过从cmd的“sysnative”版本运行powershell脚本来解决此问题:
问题解决了这个问题。在
相关问题 更多 >
编程相关推荐