home *** CD-ROM | disk | FTP | other *** search
- use Win32::OLE;
-
- my $error = AddFileExtMapping(@ARGV);
- print Win32::OLE->LastError if Win32::OLE->LastError;
- print "Press [ ENTER ] to continue:"; <STDIN>;
- exit($error);
-
- sub AddFileExtMapping {
-
- my $serverID = shift;
- my $virtDir = shift;
- my $fileExt = shift;
- my $execPath = shift;
- my $methodExclude = shift;
- my $flags = shift;
-
- my $node = "IIS://localhost/W3SVC/$serverID/ROOT";
- $node .= "/$virtDir" if length($virtDir) > 0;
-
- # Get the IIsVirtualDir Automation Object
- my $server = Win32::OLE->GetObject($node);
-
- # create our new script mapping entry
- my $scriptMapping = "$fileExt,$execPath";
- $scriptMapping .= ",$methodExclude" if length($methodExclude > 2);
- $scriptMapping .= ",$flags";
-
- my @ScriptMaps = @{$server->{ScriptMaps}};
- my @NewScriptMaps = map {
- /^\Q$fileExt,\E.*/ ? $scriptMapping : $_ } @ScriptMaps;
- push(@NewScriptMaps, $scriptMapping)
- unless grep {/^\Q$fileExt,\E.*/} @NewScriptMaps;
- print join("\n", @NewScriptMaps);
-
- $server->{ScriptMaps} = \@NewScriptMaps;
-
- # Save the new script mappings
- $server->SetInfo();
- }
-
-