VBScript en Javascript - HTA

MacGaliver Messages postés 146 Date d'inscription vendredi 28 mai 2010 Statut Membre Dernière intervention 21 juillet 2013 - 21 sept. 2011 à 17:26
cs_hackoo Messages postés 91 Date d'inscription mercredi 3 avril 2002 Statut Membre Dernière intervention 29 juillet 2013 - 23 déc. 2011 à 17:24
Bonjour,

Je voudrais convertir ce VBScript en JS (Permet de déterminer si un fichier est en lecture seule ou non).
Je souhaite l'intégrer à un fichier HTA (Application HTML).
Note: J'accepte les ActivesX.

func
Sub func()

    Dim objFSOh, objFichier
    
    Set objFSOh = CreateObject("Scripting.FileSystemObject")
    Set objFichier = objFSOh.GetFile("C:\fichier.txt")
    
    If (objFichier.Attributes And 1) Then
            valid()
        Else
            invalid()
    End If

End Sub


Par la même occasion si vous connaissez un bon cours (en française de préférence) sur le net.

Merçi d'avance.

2 réponses

cs_hackoo Messages postés 91 Date d'inscription mercredi 3 avril 2002 Statut Membre Dernière intervention 29 juillet 2013
23 déc. 2011 à 16:02
salut je ne sais pas si ça marche ceci pour vous ou non ? enregistre-le sous fichier.hta
<html>
<head>
<title>test</title>
</head>
<script language="javascript">
function func(){
    var objFSOh, objFichier;
objFSOh = new ActiveXObject("Scripting.FileSystemObject");
objFichier = objFSOh.GetFile("C:\test.txt");

    if((objFichier.Attributes && 1)){
            alert("valid");
        }
        else
{
            alert("invalid");
    }

}
</script>



</html>
0
cs_hackoo Messages postés 91 Date d'inscription mercredi 3 avril 2002 Statut Membre Dernière intervention 29 juillet 2013
23 déc. 2011 à 17:24
Salut Voila maintenant j'ai testé ce code en HTA et il marche chez-moi donc une petite rectification dans le code et ça roule
<html>
<head>
<title>test</title>
</head>
<script language="javascript">
function Attrib(file){
    var objFSOh, objFichier;
objFSOh = new ActiveXObject("Scripting.FileSystemObject");
    objFichier = objFSOh.GetFile(file);

        if((objFichier.Attributes & 1)){
        alert("Le Fichier est en Lecture Seule !");
        }
        else
{
        alert("invalid le Fichier n'est pas en lecture seule !");
    }

}
</script>



</html>
 
0
Rejoignez-nous