F
fredfrog22
The following is an extract from a C# console application that creates
a Virtual Directory on IIS 5 or 6.
This code works on XP, Windows 2003 Server, Windows 2000.
It does not work on Windows Vista Release Candidate 1 (IIS 7).
The below line
pcProps[VDPROP_PATH].Value = strPath;
throws the exception "Path not found".
Note that the user running the exe has administrator rights on the
machine.
Also, this may be a related issue:
The Microsoft VB script C:\Inetpub\Adminscripts\mkwebdir.vbs no longer
works on Windows Vista RC1 when logged in as an administrator. The
exact same script and parameters runs on Windows XP.
Interestingly, I have found that other sample code downloaded from the
Internet that creates virtual directories does not work on Vista
either.
I suspect that this is a rights issue, but I do not know how to solve
this.
Thanks for your help.
+++++++++++
Code extract:
DirectoryEntry deRoot = new DirectoryEntry(IIS_DIR);
if (null != deRoot)
try
{
// check to see if this Virtual Directory already exists
m_deVirtualDir = deRoot.Children.Add(m_strVirtualDir,
IIS_SCHEMA_VIRTUAL_DIR);
}
catch
{
try
{
String strDir = IIS_DIR + "/" + m_strVirtualDir;
m_deVirtualDir = new DirectoryEntry(IIS_DIR + "/" +
m_strVirtualDir);
}
catch
{
}
}
if (null != m_deVirtualDir)
{
// commit the changes so far!
deRoot.CommitChanges();
m_deVirtualDir.CommitChanges();
// now we need to set up some properties of the new virtual
// directory
PropertyCollection pcProps = m_deVirtualDir.Properties;
// set the Path to the Virtual Directory
string strPath = m_strIISPath + "\\" + m_strVirtualDir;
// exception generated here
pcProps[VDPROP_PATH].Value = strPath;
etc etc
a Virtual Directory on IIS 5 or 6.
This code works on XP, Windows 2003 Server, Windows 2000.
It does not work on Windows Vista Release Candidate 1 (IIS 7).
The below line
pcProps[VDPROP_PATH].Value = strPath;
throws the exception "Path not found".
Note that the user running the exe has administrator rights on the
machine.
Also, this may be a related issue:
The Microsoft VB script C:\Inetpub\Adminscripts\mkwebdir.vbs no longer
works on Windows Vista RC1 when logged in as an administrator. The
exact same script and parameters runs on Windows XP.
Interestingly, I have found that other sample code downloaded from the
Internet that creates virtual directories does not work on Vista
either.
I suspect that this is a rights issue, but I do not know how to solve
this.
Thanks for your help.
+++++++++++
Code extract:
DirectoryEntry deRoot = new DirectoryEntry(IIS_DIR);
if (null != deRoot)
try
{
// check to see if this Virtual Directory already exists
m_deVirtualDir = deRoot.Children.Add(m_strVirtualDir,
IIS_SCHEMA_VIRTUAL_DIR);
}
catch
{
try
{
String strDir = IIS_DIR + "/" + m_strVirtualDir;
m_deVirtualDir = new DirectoryEntry(IIS_DIR + "/" +
m_strVirtualDir);
}
catch
{
}
}
if (null != m_deVirtualDir)
{
// commit the changes so far!
deRoot.CommitChanges();
m_deVirtualDir.CommitChanges();
// now we need to set up some properties of the new virtual
// directory
PropertyCollection pcProps = m_deVirtualDir.Properties;
// set the Path to the Virtual Directory
string strPath = m_strIISPath + "\\" + m_strVirtualDir;
// exception generated here
pcProps[VDPROP_PATH].Value = strPath;
etc etc