############################################################################
#
# I"m not sure if you need to use both of these modules, but my code does
for some unknown reason
use Win32::OLE;
use OLE;
use Sys::Hostname;
$computer = hostname();
##########
# BEGIN block of code to add virtual roots
##########
# Get Default Web Site Object
$websvc = Win32::OLE->GetObject("IIS://$computer/W3svc/1") || die "Could not
create web service object: $!";
# Get root of Default Web Site
$vRoot = $websvc->GetObject("IIsWebVirtualDir", "Root") || die "Could not
create root of Default Web Site object: $!";
# Define %vroots as such:
%vroots = (
'vroot1' => {READ => 1,EXECUTE => 1, PATH => 'Web'},
'vroot2' => {READ => 0,EXECUTE => 1, PATH => 'Webbin'},
);
foreach $root (sort keys %vroots) {
# Delete it in case it is already there!
$vDir = $vRoot->Delete("IIsWebVirtualDir", $root);
$vDir = $vRoot->Create("IIsWebVirtualDir", $root) || next;
# Assign parameters
$vDir->{Path}="$basedir//$vroots{$root}->{PATH}";
$vDir->{AccessRead}=$vroots{$root}->{READ};
$vDir->{AccessExecute}=$vroots{$root}->{EXECUTE};
$vDir->SetInfo;
# END block of code to add virtual roots
##########
##########
# BEGIN block of code to change various properties
##########
$w3svc = Win32::OLE->GetObject("IIS://$computer/W3svc")|| die "Could not get
object: $!";
$w3svc->{AnonymousPasswordSync} = 0;
$w3svc->{AnonymousUserName} = $AnonymousUser;
$w3svc->{AnonymousUserPass} = $AnonymousPass;
$w3svc->{CGITimeout} = 86400;
$w3svc->{CreateProcessAsUser} = 1;
$w3svc->SetInfo;
$w3svc = Win32::OLE->GetObject("IIS://$computer/W3svc/1")|| die "Could not
get object: $!";
$w3svc->{CGITimeout} = 86400;
$w3svc->SetInfo;
##########
# END block of code to change properties
##########
# Some items in the metabase are more complex then simple scalars like the
above
##########
# BEGIN block of code to change mimemap--please excuse the
"not-as-elegant-as-it-could-be" code
##########
$mimemap = Win32::OLE->GetObject("IIS://$computer/MimeMap") || die "Could
not create mimemap object: $!";;
$amimemap = $mimemap->GetEx("MimeMap") || die "Could not retrieve mappings:
$!";
$alreadyThere = 0;
# Add an entry in the mime map for PNG
for ($i=0; $i<@{$amimemap}; $i++) {
($alreadyThere = 1, last) if (lc($amimemap->[$i]->{Extension}) eq
'.png');
$newmimemap = CreateObject OLE "MimeMap" || die "Could not do this: $!";
$newmimemap->{Extension} = '.png';
$newmimemap->{MimeType} = 'image/png';
push @{$amimemap}, $newmimemap;
# must use PutEx Method to set the value
$mimemap->PutEx(2, "MimeMap", $amimemap);
$mimemap->SetInfo;
# END block of code to change mimemap
##########
############################################################################
#