2010-03-10 9 views
1

J'essaie d'exécuter un script .VBS à partir de l'Explorateur Windows (IIS Manager 6) et suis une programmation VBScript novice. Je suis au-dessus de l'erreur lors de l'exécution du code suivant. Qu'est-ce que je fais mal? J'ai juste besoin de générer les types MIME IIS s'il vous plaît!Erreur d'exécution VBS 800A000D - incompatibilité de type

Détail de l'erreur: Ligne 49, car 5;
où la ligne 49:

MimeMapArray = MimeMapObj.GetEx("MimeMap") 

code fixe maintenant. Voici comment cela devrait ressembler:

' This script adds the necessary Windows Presentation Foundation MIME types 
' to an IIS Server. 
' To use this script, just double-click or execute it from a command line. 
' Running this script multiple times results in multiple entries in the IIS MimeMap. 
' Set the MIME types to be added 
Dim MimeMapObj 
Dim MimeMapArray() 
Dim WshShell 
Dim oExec 
Const ADS_PROPERTY_UPDATE = 2 

Dim MimeTypesToAddArray 
MimeTypesToAddArray = Array(".manifest", "application/manifest", ".xaml", _ 
    "application/xaml+xml", ".application", "application/x-ms-application", _ 
    ".deploy", "application/octet-stream", ".xbap", "application/x-ms-xbap", _ 
    ".xps", "application/vnd.ms-xpsdocument") 

' Get the mimemap object 
Set MimeMapObj = GetObject("IIS://LocalHost/MimeMap") 

' Call AddMimeType for every pair of extension/MIME type 
For counter = 0 to UBound(MimeTypesToAddArray) Step 2 
    AddMimeType MimeTypesToAddArray(counter), MimeTypesToAddArray(counter+1) 
Next 

' Create a Shell object 
Set WshShell = CreateObject("WScript.Shell") 

' Stop and Start the IIS Service 
Set oExec = WshShell.Exec("net stop w3svc") 
Do While oExec.Status = 0 
    WScript.Sleep 100 
Loop 

Set oExec = WshShell.Exec("net start w3svc") 
Do While oExec.Status = 0 
    WScript.Sleep 100 
Loop 

Set oExec = Nothing 

' Report status to user 
WScript.Echo "Windows Presentation Foundation MIME types have been registered." 

Dim i 
' AddMimeType Sub 
Sub AddMimeType(ByVal Ext, ByVal MType) 

    ' Get the mappings from the MimeMap property. 
    ' Add a new mapping. 
    For i = 0 to 14 
' UBound(MimeMapArray) - 1 
    ReDim Preserve MimeMapArray(i) 
    Set MimeMapArray(i) = CreateObject("MimeMap") 
    MimeMapArray(i).Extension = Ext 
    MimeMapArray(i).MimeType = MType 
    MimeMapObj.PutEx ADS_PROPERTY_UPDATE, "MimeMap", MimeMapArray 
    MimeMapObj.SetInfo() 
Next 

End Sub 

Répondre

0

Peu importe que j'ai pensé ce problème. Version correcte montrant maintenant.

Questions connexes