life runs on code

bending the technology that runs life to do your bidding

Getting the IIS log folder path using C#

You can use the Microsoft.Web.Administration namespace to obtain information about local and remote IIS configuration settings and perform administrative functions via code.  In this example, I will be using the assembly to determine the log file folder path location on a remote server for all of the sites.  It turns out that the bulk of the work is in installing and configuring the components necessary to make use of the assembly when performing operations on a remote server.
First you must add a reference to the assembly which houses the Microsoft.Web.Administration Namespace.  There are one of two ways you can do this: If you have the IIS Management Console installed, you can directly reference Microsoft.Web.Administration.dll in: %SYSTEMROOT%\SYSTEM32\InetSrv. Note that you do not actually have to have the IIS web server component installed; all you need is the Management Console. Alternatively, you can install the Microsoft.Web.Administration nuget package.  The nuget package (as of this post) is for the 7.0 version of the assembly.  While it will work with IIS8+, functionality specific to IIS 8+ will not be available.
The Microsoft.Web.Administration namespace includes several objects; however, the one we will use to get the log file folder path location is the ServerManager.  The ServerManager object is the top most configuration object.  It exposes all of the other IIS objects such as Applications, Virtual Directories, etc. If your code will be running locally on the machine which hosts IIS, then your work is done; simply create an new instance of the ServerManager Object and traverse the Sites collection and look at the Directory property of the LogFile object.
var serverManager = new ServerManager();
foreach(var site in serverManager.Sites)
System.Diagnostics.Debug.Print(System.IO.Path.Combine(site.LogFile.Directory, "WSVC"+site.Id));

Making It Work Remotely:
To use the ServerManager object with a remote server, you must make sure that your remote server has the IIS Remote Management Service installed, configured and enabled. This page will walk you through the necessary steps to get IIS Remote Management up and running; it references IIS7, but the procedure is similar for Windows Server 2012 and IIS8.  When the Remote Management Service is installed, it creates a default Windows Firewall rule for port 8172 (unless you specified a different port during configuration).  This port is important to know if you plan on connecting to the remote IIS Instance using a remote management console; however, the Microsoft.Web.Administration.dll actually uses COM to talk to the Remote Management Service.  Since we will be connecting from a remote machine to our host IIS server, we are now talking DCOM and in order for you to make things work, you will need to add appropriate Windows Firewall rules on the host IIS server to allow the inbound connection. This post will walk you through the specifics of adding the appropriate Windows Firewall rules. If you are attempting to make changes to the ahadmin COM+ package and the configuration dialog options on the Endpoints tab (and any other tabs) are grayed out see this ServerFault post.  You will have to close and re-open dcomcnfg.exe after you make the registry changes.
Once the WMSVC service is up and running, the .NET code necessary to get the log file location is relatively straight-forward; the only difference is that you invoke the ServerManager’s static OpenRemote method instead of calling the class constructor:
var serverManager = ServerManager.OpenRemote("myhost");

//the component does not actually attempt to perform the connection until you get something
foreach(var site in serverManager.Sites)
System.Diagnostics.Debug.Print(System.IO.Path.Combine(site.LogFile.Directory, "WSVC"+site.Id));

Motorola DCX3200-M User Settings

My Comcast DCX3200-M cable box is connected to a an older Sylvania 20" LCD TV model SSL2006 via a set of component cables. According to the manual, the TV "can accept [a] 480p / 480i / simplified 1080i video signal. Simplified 1080 video signal differs [from] the original 1080i video signal because it is displayed after [being] converted into [a] 480p signal."  Basically the TV scales down the 1080i output to 480p. It seems that by default my DCX3200-M cable box was preconfigured to send the component output as 720p, which meant my TV would display a “NO SIGNAL” message on the screen because it could not handle the requested resolution.

You can adjust the output component resolution, Closed Captions, Auto Power off and several other video settings of the Motorola DCX3200-M by following these steps to access the cable box’s User Settings menu:

1. Power off your cable box.

2. On the remote, tap the Menu button

The screen depicted below should appear on your TV:


You can navigate menu items using the up/down arrow keys on the remote.
You can adjust menu item values by using the left/right arrow keys on the remote.

When you are done making changes, simply press the menu key again on the remote.  Power on your cable box and the settings adjustments you have made will take effect.

Reference Manuals:

DCX3200 User Guide (1.58 mb)
Sylvania SSL2006 Owner's Manual (552.31 kb)