Daniel Fisher (lennybacon.com)

SOA, DATA & THE WEB

Don't mess with sharepoint...

Carefully said I do not like that sharepoint "hijacks" the Internet Information Server. When you create a virtual directory it is just not accessable because SharePoint took over IIS.

Funny fact: This is the second post how to fix issues with IIS and "extension" that cause issues :-)

So i decided to hack a small utility serving my needs:

ExcludeFromSharepoint.zip (3.46 KB)

Enables to exclude applications from sharepoint services through the directory context menu.
Install using the "-install" switch; Uninstall using "-uninstall" switch.

Because I'm running my machine under a LUA (Limited User Account) i wrote the tool in a way that you can install and uninstall it without administative rights - the contextmenu will be installed per user!

if(args[0]=="-install")

{

    RegistryKey _rkey = Registry.CurrentUser;

    _rkey = _rkey.OpenSubKey("SOFTWARE\\Classes",true);

    _rkey = _rkey.CreateSubKey("Folder").CreateSubKey("shell");

    _rkey = _rkey.CreateSubKey("Exclude from Sharepoint");

    _rkey = _rkey.CreateSubKey("command");

    _rkey.SetValue(null, App.Application.ExecutablePath + " \"%1\"");

}

else if(args[0]=="-uninstall")

{

    RegistryKey _rkey = Registry.CurrentUser;

    _rkey = _rkey.OpenSubKey("SOFTWARE\\Classes\\Folder\\shell",true);

    _rkey.DeleteSubKeyTree("Exclude from Sharepoint");

}

else

{

...

}

 

The Implementation works with the webserver extensions version 4.0 or higher

 

    RegistryKey _rkey = Registry.LocalMachine;

    _rkey = _rkey.OpenSubKey("SOFTWARE\\Microsoft\\Shared Tools\\" +

        "Web Server Extensions",true);

   

    foreach(string _subKeyName in _rkey.GetSubKeyNames())

    {

        try

        {

            int.Parse(_subKeyName.Replace(".",""));

            RegistryKey _fpKey = _rkey.OpenSubKey(_subKeyName,true);

            _fpDir = (string)_fpKey.GetValue("Location");

        }

        catch(Exception _ex)

        {

            string _err = _ex.ToString();

            break;

        }

    }

 

and uses the stsadm.exe from the shared tools of the server extensions.

    System.Diagnostics.Process _p = new System.Diagnostics.Process();

    _p.StartInfo.FileName = Path.Combine(_fpDir, "BIN\\stsadm.exe");

    _p.StartInfo.Arguments = "-o addpath -url http://localhost/" +

        _strProjectName + " -type exclusion";

    ...

    _p.Start();

 

Comments

Write a comment