IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBScript Discussion :

Script VBS Solution ?


Sujet :

VBScript

  1. #1
    Membre à l'essai
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2016
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Novembre 2016
    Messages : 11
    Points : 11
    Points
    11
    Par défaut Script VBS Solution ?
    Bonjour à tous,
    Actuellement entrain d'essayer de coder un petit script VBS je me retrouve confronté à une difficulté , manque de connaissance

    Mon script consiste à demander à l'utilisateurs des informations concernant un prêt de matériel informatique ou un retour en y indiquant la date , l'heure, le nom , et le type de matériel.
    Jusque la tout va bien!

    Par la suite ou plutôt à la fin du script ce qui se passe c'est que j'exporte les résultats de ce dernier dans deux fichiers texte. Emprunt et Retour.

    Mon souhait serait par exemple de pouvoir :
    - réunir toutes les infos sur un seul fichier texte ( sans qu'il m'écrase ce dernier à chaque fois )
    - Inserer une couleur pour les entrées sorties dans le fichier texte


    Je vous remercie d'avance si jamais vous avez d'autres idées, ou pour toutes informations qui me sera apportée !!



    Mon script :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    strtexte = "projet Test script entree sortie materiel informatique"
     
     
    ' Partie box avec bouton oui non annuler '
    valbout = msgbox("EMPRUNT de materiel ?   ", 35, "Service Informatique")
    if valbout = 6 Then
    ' Debut du script '
    ' Mot de passe '
    MotDePasse = "toto"
    MonTest = inputbox("Entrez le mot de passe : ", "Service Informatique")
    If MonTest = MotDePasse Then
    Dateetheure = inputbox("Date et heure  " , "Service Informatique")
    wscript.echo "Date et heure de l'emprunt " & Dateetheure
    Personne = inputbox("Nom de la personne? " , "Service Informatique")
    wscript.echo "Emprunt par : " & Personne
    Materiel = inputbox("Quel est le materiel? " , "Service Informatique")
    wscript.echo "Type de Materiel : " & Materiel
    wscript.echo "Recapatiulatif : " & Dateetheure & " " & Personne & " Emprunte " & Materiel
    ' Creation du fichier .txt recapitulatif '
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.CreateTextFile("C:\Users\xxxx\desktop\EMPRUNT-Materiel.txt")
    objFile.Write ("RECAPITULATIF EMPRUNT-Materiel ||  ") & Dateetheure & " || " & Personne & " || " & Materiel 
    objFile.close
    Else
    Msgbox "MOT DE PASSE INCCORECT"
    End If
    wscript.quit
    End if
     
     
     
     
    ' Partie box avec bouton oui non annuler '
    valbout = msgbox("RETOUR de materiel ?   ", 35, "Service Informatique")
    if valbout = 6 Then 
    ' Debut du script '
    ' Mot de passe '
    MotDePasse = "toto"
    MonTest = inputbox("Entrez le mot de passe : ", "Service Informatique")
    If MonTest = MotDePasse Then
    Dateetheure = inputbox("Date et heure  " , "Service Informatique")
    wscript.echo "Date et heure de l'emprunt " & Dateetheure
    Personne = inputbox("Nom de la personne? " , "Service Informatique")
    wscript.echo "Emprunt par : " & Personne
    Materiel = inputbox("Quel est le materiel? " , "Service Informatique")
    wscript.echo "Type de Materiel : " & Materiel
    wscript.echo "Recapatiulatif : " & Dateetheure & " " & Personne & " Emprunte " & Materiel
    ' Creation du fichier .txt recapitulatif '
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.CreateTextFile("C:\Users\xxxx\desktop\RETOUR-Materiel.txt")
    objFile.Write ("RECAPITULATIF RETOUR-Materiel ||  ") & Dateetheure & " || " & Personne & " || " & Materiel 
    objFile.close
    Else
    Msgbox "MOT DE PASSE INCCORECT"
    End If
    wscript.quit
    End if

  2. #2
    Membre averti
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2011
    Messages
    163
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Novembre 2011
    Messages : 163
    Points : 304
    Points
    304
    Par défaut
    Salut !

    Voici un petit script .HTA

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    <title>Emprunt_Retour_Matériel</title>
    <HTA:APPLICATION
    APPLICATIONNAME="Service Informatique"
    BORDER="thin"
    SCROLL="no"
    SINGLEINSTANCE="yes"
    WINDOWSTATE="normal"></head>
     
    <script language="VBScript">
     
    Mdp = "toto"
    Fichier_Log = ".\Emprunt_Retour_Materiel.csv"
     
    Sub Window_onLoad
    Me.ResizeTo 400,360
    Me.MoveTo ((Screen.Width / 2) - 200),((Screen.Height / 2) - 180)
    End Sub
     
    Sub Default_Buttons
    If Window.Event.KeyCode = 13 Then
    btn_Valider.Click
    End If
    End Sub
     
    Sub Get_Valider
    strEtat = LstEtat.value
    strMdp = txt_mdp.value
    strDate = txt_date.value
    strUtil = txt_util.value
    strMateriel = txt_materiel.value
     
    if strEtat = "" or strMdp = "" or strDate="" or strUtil="" or strMateriel="" Then
    msgbox "Informations manquantes"&vbCrLf&"Veuillez Compléter",vbOKOnly,"Erreur"
    Exit Sub
    End If
     
    if strMdp<>Mdp Then
    msgbox "Mot de passe erroné"&vbCrLf&"Réessayez",vbOKOnly,"Erreur"
    Exit Sub
    End If
     
    Const ADS_SCOPE_SUBTREE = 2, ForReading = 1, ForWriting = 8
    Dim oFSO, ecr, txt_entree
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    if oFSO.FileExists(Fichier_Log) = False Then oFSO.CreateTextFile(Fichier_Log)
    txt_entree = strEtat & ";" & strDate & ";" & strUtil & ";" & strMateriel & vbCrLf
    set ecr = oFSO.OpenTextFile(Fichier_log, ForWriting) : ecr.Write(txt_entree) : ecr.Close
     
    MsgBox "Entrée ajoutée", vbOKOnly
     
    End sub
    </script>
     
    <body>
     
    <p align="center">EMPRUNT RETOUR DE MATERIEL</p></br>
     
    <p align="center"> Sélectionnez   
    <SELECT NAME="LstEtat" SIZE=1>
    <OPTION VALUE="Emprunt">-- EMPRUNT --
    <OPTION VALUE="Retour"">-- RETOUR --
    </SELECT></p>
     
    <p align="center">Mot de passe   
    <input type="text" value="" name="txt_mdp" maxlength='10' size='11'></p>
     
    <p align="center">Date   
    <input type="text" value="" name="txt_date" maxlength='10' size='11'></p>
     
    <p align="center">Utilisateur   
    <input type="text" value="" name="txt_util" maxlength='25' size='26'></p>
     
    <p align="center">Matériel   
    <input type="text" value="" name="txt_materiel" maxlength='25' size='26'>
    </p>
     
    <tr height='30%'><p align='center'><input type="button" value="Valider" name="btn_Valider"  onClick="Get_Valider"></p></tr></body>
    ++

  3. #3
    Membre à l'essai
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Novembre 2016
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux

    Informations forums :
    Inscription : Novembre 2016
    Messages : 11
    Points : 11
    Points
    11
    Par défaut Waoh
    Juste Woah ! c'est parfait!
    Je vais prendre le temps d'analyser tout ça pour comprendre comment le script est fait , mais c'est juste excellent .
    Milles merci !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 4
    Dernier message: 28/12/2005, 13h39
  2. Script VBS - Focus garder la fenêtre en premier plan
    Par Furius dans le forum VBScript
    Réponses: 4
    Dernier message: 12/12/2005, 23h27
  3. Réponses: 2
    Dernier message: 19/07/2005, 14h14
  4. Probleme recuperation d'une valeur : script vbs -> .bat
    Par pinpin_du_net dans le forum Windows
    Réponses: 3
    Dernier message: 10/05/2005, 12h43
  5. Imprimer un fichier texte avec un script vbs
    Par Persons dans le forum Windows
    Réponses: 3
    Dernier message: 23/12/2004, 16h47

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo