[python-win32] Delete IIS website via wmi

Sten Spans sten at blinkenlights.nl
Thu Nov 15 16:20:53 CET 2007


I'm rewriting some iis management scripts in python,
using the python wmi bindings from http://tgolden.sc.sabren.com/python/wmi.html

Creating / Ennumerating sites works just fine.
But I can't seem to figure out how to delete sites.

import wmi

iis = wmi.WMI(namespace = "MicrosoftIISv2")

''' locate a the first website'''
website =  iis.IIsWebServerSetting()[0]

''' locate it's webserver '''
webserver = iis.IIsWebServer(Name="%s" % website.name)[0]

''' stop the webserver '''
webserver.Stop()

''' delete the website '''
website.Delete()

results in:

D:\test>c:\Python25\python.exe test.py
Traceback (most recent call last):
   File "test.py", line 16, in <module>
     website.Delete()
   File "c:\Python25\Lib\site-packages\wmi.py", line 472, in __getattr__
     return getattr (self.ole_object, attribute)
   File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 
496, in
__getattr__
     raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: <unknown>.Delete


Any hints ?

-- 
Sten Spans

"There is a crack in everything, that's how the light gets in."
Leonard Cohen - Anthem


More information about the python-win32 mailing list