#!perl -w use strict; use Carp; use Win32; use Win32::OLE; printdir(@ARGV); my $newitem; sub printdir { my $item; foreach $item(@_) { next if $item =~ /\.{1,2}$/; if (-d $item) { $newitem = $item; $newitem =~ s/\A[^\/]+//; &SetRedirect($newitem); print "Processed $newitem\n"; opendir(SUBDIR, $item) or croak "Can't open directory :$!" +; my @subdir_items = readdir(SUBDIR); #+ closedir(SUBDIR); #+ printdir(map {"$item/$_"}@subdir_items); #+ } } } sub SetRedirect { my $newdir = shift; my $hostname = "my.server.com"; my $websvc=Win32::OLE -> GetObject("IIS://$hostname/W3SVC/1"); # Get root of Default Web Site my $vRoot = $websvc->GetObject("IIsWebVirtualDir", "Root") || die +"Could not create root of Default Web Site object: $!"; my $root = "thedir$newdir"; if ($newdir) { my $vDir = $vRoot->Create("IIsWebVirtualDir", $root); # Print out the current value of some properties: print "Before: " . $vDir->{"HttpRedirect"} . "\n"; # Set some properties: $vDir->{"HttpRedirect"}="https\://my\.server\.com/thedir\$S\$Q +, EXACT_DESTINATION"; # Save the property changes in the metabase: $vDir->SetInfo(); print "After: " . $vDir->{"HttpRedirect"} . "\n"; } }
In reply to Perl Sets IIS Redirects by LostS
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |