cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
PlinyElder
Level 7

Installscript: Get IIS WebSites with WMI

I am trying to a list of websites from the local machine that IIS has available. I am trying to use the CoGetObject to access WMI but i cannot get it to work any ways that i have been able to find online. Ultimately i am trying to get the Virtual Directory path for any current website that may exist on the users machine before install or upgrade.

What i have tried so far is not working for me. Anyone have something working with IIS 7.5 on Win7 x64?


set oIISRoot = CoGetObject("IIS://localhost/W3SVC","");



set oIISRoot = CoGetObject("winmgmts:\\.\root\CIMV2", "");



set oIISRoot = CoGetObject("IIS://localhost/W3SVC/1/ROOT");
I have had limited success on some machines with this


I've tried these same pieces of code for GetObject as well with no success
Labels (1)
0 Kudos
(3) Replies
PlinyElder
Level 7

Anyone have any suggestions?
0 Kudos
rguggisberg
Level 13

From a command prompt or bat file do this:
set "appcmd=%windir%\system32\inetsrv\appcmd.exe"
%appcmd% list site
0 Kudos
PlinyElder
Level 7

rguggisberg wrote:
From a command prompt or bat file do this:
set "appcmd=%windir%\system32\inetsrv\appcmd.exe"
%appcmd% list site


I ended up taking this route. appcmd.exe can handle what i need it too. Thanks
0 Kudos