0
環境IIS7創建應用程序/ ApplicationPool:的Windows 2008 R2 x64的,IIS 7無法通過WMI
我嘗試添加 「應用」 和 「應用程序池」 到IIS。 IIS已配置並運行良好。我手動添加了網站/應用程序 - 並且它們也很好地工作。
import wmi
oWebAdmin = wmi.GetObject(r"winmgmts:root\WebAdministration")
strApplicationPath = "/my_site"
strSiteName = "Default Web Site"
strPhysicalPath = r"C:\Windows\SysNative\certsrv\mscep"
#fails here:
oWebAdmin.Get('Application').Create(strApplicationPath, strSiteName, strPhysicalPath)
oWebAdmin.Get("ApplicationPool").Create("NewAppPool")
我得到的錯誤:
Traceback (most recent call last):
File "C:\work\selenium-project\mdm-setup-assistant\ndes\install_dnes_service.py", line 23, in <module>
oWebAdmin.Get('Application').Create(strApplicationPath, strSiteName, strPhysicalPath)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 505, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'SWbemObjectEx', u'Invalid parameter ', None, 0, -2147217400), None)
有趣的部分是,.Create()
from msdn說,所有我把參數是有效的。
什麼有我想:
1)首先創建應用程序池(不過爲了不應該的問題,因爲我需要綁定它們都是在創建時)
oWebAdmin.Get("ApplicationPool").Create("NewAppPool")
和中,當然,我得到非常類似的錯誤:
Traceback (most recent call last):
File "C:\work\selenium-project\mdm-setup-assistant\ndes\install_dnes_service.py", line 17, in <module>
oWebAdmin.Get("ApplicationPool").Create("NewAppPool")
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 505, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'SWbemObjectEx', u'Invalid parameter ', None, 0, -2147217400), None)
2)我試圖列出應用程序。這工作:
oApps = oWebAdmin.InstancesOf("Application")
for app in oApps:
print app.SiteName
print app.Path
print app.ApplicationPool
print app.EnabledProtocols
輸出:
Default Web Site
/
DefaultAppPool
http
Default Web Site
/CertSrv/mscep_admin
SCEP
http
Default Web Site
/CertSrv/mscep
SCEP
http
MyApp
/
MyApp AppPool
http
可能是什麼毛病我.Create()
電話?
注:我與提升的權限運行(如果該事項)
UPDATE:能.Get
被失敗?:不,這是definetely .Create()
:
app = oWebAdmin.Get('Application')
#fails here:
app.Create(strApplicationPath, strSiteName, strPhysicalPath)
錯誤:
Traceback (most recent call last):
File "C:\work\selenium-project\mdm-setup-assistant\ndes\install_dnes_service.py", line 18, in <module>
app.Create(strApplicationPath, strSiteName, strPhysicalPath)
File "C:\Python27\lib\site-packages\win32com\client\dynamic.py", line 505, in __getattr__
ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, u'SWbemObjectEx', u'Invalid parameter ', None, 0, -2147217400), None)
不,它絕對是'.Create()'。我已經用信息更新了這個問題。謝謝,不過。 –