Comment: lets find out which IIS we're working with
Get System Setting Internet Information Server 7 into IIS7
Get System Setting Internet Information Server 6 into IIS6
Get System Setting Internet Explorer 5.0 into IIS5
Comment: display the main dialog and retrieve the website's name
Set Variable WEBSITE to 
Display Dialog: main, wait for dialog to return (modal)
Comment: get our Windows directory
Get Common Folder Location System->Windows Directory into WINDOWSDIR
if Variable IIS7 Equals TRUE
  Comment: save the file name of appcmd.exe
  Set Variable APPCMD to $WINDOWSDIR$system32\inetsrv\appcmd.exe
  Comment: run our batch file and pass the appropriate parameters
  Run Program $SUPPORTDIR$run_appcmd.bat "$APPCMD$"  list site "$WEBSITE$" "$TEMPDIR$appcmdoutput.txt" (WAIT)
  Comment: read from the text file that has the stdout of appcmd
  Read from Text File $TEMPDIR$appcmdoutput.txt into Variable APPCMDOUTPUT
  Delete Files $TEMPDIR$\appcmdoutput.txt (when installing)
  Apply Install
  Comment: parse the file and extract the TCP port
  Parse String $APPCMDOUTPUT$ into Variables  and APPCMDOUTPUT (Split at first occurrence of pattern)
  Parse String $APPCMDOUTPUT$ into Variables TCPPORT and  (Split at first occurrence of pattern)
  if Variable TCPPORT not Equals 
    MessageBox: Success, $WEBSITE$'s TCP port: $TCPPORT$
  else
    MessageBox: Error, TCP port could not be retrieved.
  end
else
  if Variable IIS6 Equals TRUE
    Comment: save the file name of cscript.exe and iisweb.vbs
    Set Variable IISWEB to $WINDOWSDIR$system32\iisweb.vbs
    Set Variable CSCRIPT to $WINDOWSDIR$system32\cscript.exe
    Comment: run our batch file and pass the appropriate parameters
    Run Program $SUPPORTDIR$run_iisweb.bat "$CSCRIPT$" "$IISWEB$" /query "$WEBSITE$" "$TEMPDIR$iisweboutput.txt" (WAIT)
    Comment: read from the text file that has the stdout of iisweb
    Read from Text File $TEMPDIR$iisweboutput.txt into Variable IISWEBOUTPUT
    Delete Files $TEMPDIR$\iisweboutput.txt (when installing)
    Apply Install
    Comment: parse the file and extract the TCP port
    Comment: trim the two white spaces to get to the TCP port
    Parse String $IISWEBOUTPUT$ into Variables  and IISWEBOUTPUT (Split at first occurrence of pattern)
    Parse String $IISWEBOUTPUT$ into Variables  and IISWEBOUTPUT (Split at first occurrence of pattern)
    Parse String $IISWEBOUTPUT$ into Variables TCPPORT and  (Split at first occurrence of pattern)
    if Variable TCPPORT not Equals 
      MessageBox: Success, $WEBSITE$'s TCP port: $TCPPORT$
    else
      MessageBox: Error, TCP port could not be retrieved.
    end
  else
    if Variable IIS5 Equals TRUE
      Comment: save the file name of cscript.exe and adsutil.vbs
      Set Variable CSCRIPT to $WINDOWSDIR$system32\cscript.exe
      Set Variable ADSUTIL to C:\Inetpub\AdminScripts\adsutil.vbs
      Comment: run our batch file and pass the appropriate parameters
      Get IIS Index for Site "$WEBSITE$" into WEBSITEINDEX
      Run Program $SUPPORTDIR$run_adsutil.bat "$CSCRIPT$" "$ADSUTIL$" get $WEBSITEINDEX$ "$TEMPDIR$\adsutiloutput.txt" (WAIT)
      Comment: read from the text file that has the stdout of adsutil
      Read from Text File $TEMPDIR$adsutiloutput.txt into Variable ADSUTILOUTPUT
      Delete Files $TEMPDIR$\adsutiloutput.txt (when installing)
      Apply Install
      Comment: Comment: parse the file and extract the TCP port
      Parse String $ADSUTILOUTPUT$ into Variables  and ADSUTILOUTPUT (Split at first occurrence of pattern)
      Parse String $ADSUTILOUTPUT$ into Variables TCPPORT and  (Split at first occurrence of pattern)
      if Variable TCPPORT not Equals 
        MessageBox: Success, $WEBSITE$'s TCP port: $TCPPORT$
      else
        MessageBox: Error, TCP port could not be retrieved.
      end
    end
  end
end
 
