Groups | Blog | Home
all groups > iis ftp > february 2005 >

iis ftp : How to programmatically create/remove FTP virtual directory



William Sonner
2/16/2005 12:01:15 PM
Hi,

I'm trying to create and remove an FTP virtual directory on Windows 2000
programmatically (as part of an install/uninstall routine) and the means I'm
using are probably not the best way of doing this. But here's what I'm
doing.

I open the registry entry
HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\MSFTPSVC\\Parameter
s\\Virtual Roots and add the string string value (key) "/myvirtualroot" with
a value "C:\mydirectory,,3". After rebooting the computer, the virtual
directory is listed in the Internet Information Services tool (IIS tool) and
the directory is working with read/write permissions.

Now when I want to uninstall the virtual directory, I am attempting to
delete this registry key (which gets deleted successfully) and then reboot
the computer. After the computer is rebooted, this key reappears in the
registry and the IIS tool also still lists the virtual directory. I've
tried stopping the IIS Admin Service and the FTP Publishing Service prior to
deleting the registry key but I get the same results. If I use the IIS tool
to delete the virtual directory, it works.

Does anybody have any ideas on this? Is there a set of Windows32 API
functions I can call to install/uninstall an FTP virtual directory? So far
I have not been able to find anything more on this in the MSDN
documentation.

I would appreciate any help. Thanks.
Bill

Bernard
2/17/2005 12:23:28 PM
You can open IIS help file then look for administration scripts with W2k.
or you can get it here online -
http://www.microsoft.com/windows2000/en/server/iis/

Take a look at adsutil.vbs. You can use ADSI to manipulate IIS.

--
Regards,
Bernard Cheah
http://www.tryiis.com/
http://support.microsoft.com/
http://www.msmvps.com/bernard/



[quoted text, click to view]

William Sonner
2/22/2005 10:15:47 AM
Hi,

I'm still not having any luck with this. The articles I've read discuss
using VBScript, JScript or Perl or they refer to tools supplied with Windows
2003 Server. I am using Windows 2000 Professional which runs on an embedded
PC and I am trying to remove the FTP server through C++. I have been able
to gleen some useful info out of this though. Here is what I've
discovered...

As a refresher, I have a FTP server called "mcos"

I am using the ADsGetObject function as in...

IADs* pObject = NULL;
HRESULT hr = ADsGetObject(_T("IIS://localhost/MSFTPSVC/1/ROOT/MCOS"),
IID_IADs, (void**)&pObject);
if (SUCCEEDED(hr))
{
pObject->Release();
}

The above code works and returns an object. Yet I question whether I've got
the pathname right?

However, when I try to get the IDirectoryObject interface on this object, or
it's parent object, the call returns E_NOINTERFACE. I get the impression
that I want the IDirectoryObject interface so that I can call DeleteDSObject
on it. It this correct?

Coding example.

IDirectoryObject* pDir = NULL;
HRESULT hr = ADsGetObject(_T("IIS://localhost/MSFTPSVC/1/ROOT/MCOS"),
IID_IDirectoryObject, (void**)&pDir);
if (SUCCEED(hr))
{
...
}

The above call fails. Any ideas why? Are these interfaces supported under
Windows 2000 Professional?

Thanks again, Bill


[quoted text, click to view]

Bernard
2/23/2005 11:03:04 AM
You might want to post to C++ group then. Most of us here use ADSI to
management IIS.
here's one example of removing website virtual directory
http://www.iisfaq.com/Default.aspx?tabid=3002

just change the key type to IIsFtpVirtualDir. This should work on w2k pro as
well.

--
Regards,
Bernard Cheah
http://www.tryiis.com/
http://support.microsoft.com/
http://www.msmvps.com/bernard/



[quoted text, click to view]

AddThis Social Bookmark Button