Enumerate Websites in Vista
-
Just trying to get a list of websites for IIS7. First we start here:
TempVBS2(WINSYSDIR ^ "inetsrv" ^ "appcmd.exe list site /text:site.name > " + FOLDER_TEMP ^ "site.names");
Next interesting bit in function TempVBS2:
if (LaunchAppAndWait(WINSYSDIR ^ "CScript.exe", SUPPORTDIR ^ "tmpbat2.vbs \"" + strCommand + "\" " + FOLDER_TEMP ^ "Magic.bat", LAAW_OPTION_HIDDEN + LAAW_OPTION_WAIT + LAAW_OPTION_WAIT_INCL_CHILD) < 0) then
Ok so now lets run some VBScript:
myCmd = argObj(0)
batFile = argObj(1)
myCmd = Replace(myCmd, "'", Chr(34))
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set oTS = oFSO.CreateTextFile(batFile)
oTS.WriteLine myCmd
oTS.Close
cmdCmd = "cmd /C " & batFile
Set oShell = CreateObject("WScript.Shell")
Call oShell.Run(cmdCmd, 0, True)Great!! At this point its 50/50 whether or not the command actually ran. Assuming it did we then:
if (OpenFile(nFileHandle, FOLDER\_TEMP, "site.names") < 0) then abort; endif; ret = ListCreate(STRINGLIST); while (GetLine(nFileHandle, sLine) = 0) ListAddString(ret, sLine, AFTER); endwhile; if (CloseFile(nFileHandle) < 0) then abort; endif;
And VOILA!! We have our list of websites. Simple, elegant, mind-numbing. By the way if anyone is interested this is mostly InstallScript.