3

I'm trying to get the current IIS application name in my ColdFusion scripts but I have no idea where to get this information. I want to use the app name to communicate with IIS using cfexecute by running appcmd.exe.

<cfexecute name="c:\windows\system32\inetsrv\APPCMD" arguments="add site /name:#arguments.sitename# /bindings:""http/*:80:#arguments.binding#"" /physicalPath:""#arguments.physicalPath#""" timeout="60"></cfexecute>

The problem is that I can't be sure what the app name is. I could save it somewhere in a db but i'd really like to get it dynamically so the script can run without configuring the appname. If I could be able to fetch it from somewhere (or maybe based on the current hostheader) I could dynamically fill

/name:#arguments.sitename#

I've tried to search how to do this by using PHP and JSP examples, but so far, i haven't been able to find any method on getting the app name.

Jelle Kralt
  • 980
  • 6
  • 16
  • So you have found PHP & JSP examples that *work*? Can you pls include links to them in your question? – Adam Cameron Jan 05 '14 at 13:20
  • No, I haven't found them unfortunately. – Jelle Kralt Jan 05 '14 at 14:26
  • Does IIS not have an API you can talk to? – Adam Cameron Jan 05 '14 at 15:12
  • Sortof, appcmd.exe can be used for some stuff, but I havent been able to find anything about getting an app name or even a list of app names with appcmd. I believe there are other methods but as far as I can tell they are only available when using a .net language (asp/c#). – Jelle Kralt Jan 05 '14 at 19:56
  • 1
    But you can call .net objects from CF easily enough... http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Part_4_CF_DevGuide_1.html – Adam Cameron Jan 05 '14 at 22:44
  • Don't quite understanding what you asking for so I may be off here... If your app is written in ColdFusion and you want its name you could use #application.ApplicationName#. It's a application level variable you setup in your Application.cfc file. Example: – gfrobenius Jan 06 '14 at 04:08
  • @AdamCameron That might be a good idea, I haven't tried calling .net objects before but i'll give it a go. – Jelle Kralt Jan 06 '14 at 07:57
  • @gfrobenius I'm not trying to get or change the ColdFusion application name but the application name of the IIS application. I'd like to get that name dynamically so I can add bindings and mappings with ColdFusion. – Jelle Kralt Jan 06 '14 at 07:59
  • @AdamCameron on second thoughts, this might be an impossible solution. The project I want to use this on is our website "core" which supports ColdFusion and Railo. As .net is unavailable in Railo i'm afraid I won't be able to use this. – Jelle Kralt Jan 06 '14 at 09:22
  • You could automate in CF, and offer manual steps for Railo? If poss I'd not drag it down to the lowest common denominator, rather play to the strengths of each platform? Just a suggestion. – Adam Cameron Jan 06 '14 at 12:42
  • You need the host name/domain name. Am I right? I think this will get from [CGI](http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Expressions_8.html) Scope. – lambypie Jan 06 '14 at 13:09
  • @AdamCameron You absolutely have a point, but in this specific case i'd really like to find a way do it on both platforms. If it turns out to be very complicated I might choose to save the iis app name to a db field after all. I just hoped there would be a nicer way :). – Jelle Kralt Jan 06 '14 at 13:51
  • @lambypie No, I need the application/site name that is used by IIS to name the iis site. – Jelle Kralt Jan 06 '14 at 13:53
  • 1
    **I am not sure of the security ramifications, _if any_, of doing the following but here is a thought.** You did not indicate which version of IIS you are using. In later versions of IIS all of the settings are written to XML files on the server. I believe this began with IIS 7. Theoretically you could give ColdFusion rights to read the XML file and retrieve the information you are after. But I'm not so sure I would do this. Those XML files are the core of your IIS installation. Any changes could be detrimental to your server. – Miguel-F Jan 06 '14 at 14:26
  • _edit - I removed the link I had in my previous comment as it referred to IIS 6_. Here is a more relevant one. [See this reference.](http://www.iis.net/learn/get-started/planning-your-iis-architecture/iis-7-and-iis-8-configuration-reference) – Miguel-F Jan 06 '14 at 14:28
  • @Miguel-F That is actually a pretty good idea. I'm using IIS7 or up on all of my servers so this might actually work. As long as I don't change the XML it shouldn't break. That being said, I'm still not sure if I want to do this. It's an idea to think about though, thanks! – Jelle Kralt Jan 06 '14 at 22:05

1 Answers1

0

Following on from @Miguel-F's link (http://www.iis.net/learn/get-started/planning-your-iis-architecture/iis-7-and-iis-8-configuration-reference) in the comments above, there's a file in %windir%\system32\inetsrv\config\ called applicationHost.config that you could read in - this file contains the collection of sites that's configured in IIS. Is that the sort of thing you're after?