Error: Subscript out of range script vbs

Résolu
Bonjour,

J'ai faite un script qui prend un nom de fichier depuis la ligne de commande (cmd) et affiche toutes les propriété de l'objet File correspondant. Le script doit décoder aussi les attributs de fichier renvoyés.

le probleme quand je l'exécute j'ai un erreur :

Error Message:

Windows Script Host

Script: C:\userlocationchange.vbs
Line: 19
Char: 1
Error: Subscript out of range: '[number: 1]'
Code: 800A0009
Source: Microsoft VBScript runtime error


Merci de vos réponse

If NomFic = " " Then
Set FSO = CreateObject("Scripting.FileSystemObject")
NomFic = WScript.Arguments(0)

If FSO.FolderExists(NomFic) Then

'******** récupere attibuts

If NomFic.Attributes And 1 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

If NomFic.Attributes And 2 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

If NomFic.Attributes And 4 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

If NomFic.Attributes And 8 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

If NomFic.Attributes And 16 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

If NomFic.Attributes And 32 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

If NomFic.Attributes And 64 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

If NomFic.Attributes And 128 Then
strAttributs = "Fichier en lecture seule" & vbCrLf
End If

MsgBox "Le fichier possède les attributs: " & vbCrlf & StrAttibuts & NomFic.DateCreated &_
"Dernier modification" & NomFic.Date.LastModified & "Votre lecteur" & NomFic.Drive &_
"Nom du fichier" & NomFic.Name & "Le size du fichier" & NomFic.Size / 1024 & "Ko" &_
"Le type de fichier" & NomFic.Type

Else

MsgBox "Le fichier spécifié n'exite pas", vbExclamation

End If

4 réponses

  1. Contributeur
    Bonjour,
    Il te manque le dernier End If
    A+
    1. Merci lermitte222 et bonne année.
  2. Contributeur
    Et tu a encore une autre erreur,
    Dans le libellé de ton MsgBox, il faut un espace entre les & _
    Ce que tu n'a pas fais.