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 :

[VBS] lancer un programme en vbS


Sujet :

VBScript

  1. #1
    Membre à l'essai
    Inscrit en
    Janvier 2004
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 13
    Points : 10
    Points
    10
    Par défaut [VBS] lancer un programme en vbS
    salut j'aimerai faire cela en vbs...:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    Private Sub UserForm_Initialize()
    Dim ret
    ret = Shell("C:\Program Files\Claris Corp\FileMaker Pro 4.0\FileMaker Pro.exe c:\mail.fp3", vbNormalFocus)
     
    End Sub
    j'ai remarqué que cela ne fonctionnait pas.... les fonctions different elles enormement ?
    est il possible de réaliser un ".exe" avec du vbs sans passer par une compilation vb6 ?
    merci

  2. #2
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Bonjour,

    MSDN a dit :

    Microsoft® Windows® Script Host
    Run Method WSH Reference
    Version 1

    Applies To


    --------------------------------------------------------------------------------

    Description
    Creates a new process that executes strCommand.
    Syntax
    object.Run (strCommand, [intWindowStyle], [bWaitOnReturn])
    Parameters
    Part Description
    object WshShell object.
    strCommand Environment variables within the strCommand parameter are automatically expanded.
    intWindowStyle Optional. Sets the window style of the program being run.
    bWaitOnReturn Optional. If bWaitOnReturn is not specified or FALSE, immediately returns to script execution rather than waiting for the process to end.
    If bWaitOnReturn is set to TRUE, the Run method returns any error code returned by the application.

    If bWaitOnReturn is not specified or is FALSE, the Run method returns an error code of 0 (zero).



    Remarks
    The following table lists the available settings for intWindowStyle:
    intWindowStyle Description
    0 Hides the window and activates another window.
    1 Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
    2 Activates the window and displays it as a minimized window.
    3 Activates the window and displays it as a maximized window.
    4 Displays a window in its most recent size and position. The active window remains active.
    5 Activates the window and displays it in its current size and position.
    6 Minimizes the specified window and activates the next top-level window in the Z order.
    7 Displays the window as a minimized window. The active window remains active.
    8 Displays the window in its current state. The active window remains active.
    9 Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
    10 Sets the show state based on the state of the program that started the application.



    Example
    The following example runs Microsoft Notepad and opens the currently running script:
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run ("%windir%\notepad" & WScript.ScriptFullName)
    The following example returns the error code from the executed application:
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Return = WshShell.Run("notepad " & WScript.ScriptFullName, 1, TRUE)

    --------------------------------------------------------------------------------

  3. #3
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Je suis désolé, c'est un copier/coller de la doc que je possède, et malheureusement, elle est en patois.

  4. #4
    Membre éclairé
    Avatar de Catbull
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    542
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 542
    Points : 854
    Points
    854
    Par défaut
    Citation Envoyé par méphistopheles
    oui enfin je rappele que c'est quand-même un forum en français.
    Les documents de la KB et de MSDN sont majoritairement en anglais. Tu peux toujours faire une recherche sur msdn.microsoft.com, ces documents sont peut-être traduit en francais.

    PS : pc75 fait la recherche à ta place et tu trouves le moyen de déprecier cette aide. Tu devrais changer d'attitude et devenir autonome.

  5. #5
    Membre à l'essai
    Inscrit en
    Janvier 2004
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    merci le code est tout à fait compréhensible .

    je veux lancer mon fichier vbs et faire en sorte qu'il tourne pour lancer mon application chaque jour à une date précise ....

  6. #6
    Membre à l'essai
    Inscrit en
    Janvier 2004
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    hum y aurait t il un get(date) en vbs ?

  7. #7
    Membre éclairé
    Avatar de Catbull
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    542
    Détails du profil
    Informations personnelles :
    Âge : 46
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 542
    Points : 854
    Points
    854
    Par défaut
    Utilise la fonction now

    PS : ou day, month, year

  8. #8
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Ou le planificateur de tâches ?

  9. #9
    Membre à l'essai
    Inscrit en
    Janvier 2004
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    dans mon cas le planificateur est inefficace , du coup je me retrouve à réaliser en urgence une m*** de script pour lancer ma tache journaliere.
    n'ayant pas visual ici meme, je ne peux que le faire en vbs...
    (pas le batch, ne marcheras pas)
    donc je veux juste lancer une appli comme cela :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    if hour() = now() then
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run ("c:\mail.fp3")
    end if
    en bref chaque jour je veux le lancer à une heure precise...

  10. #10
    Expert confirmé
    Avatar de pc75
    Profil pro
    Inscrit en
    Septembre 2004
    Messages
    3 662
    Détails du profil
    Informations personnelles :
    Âge : 68
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Septembre 2004
    Messages : 3 662
    Points : 4 047
    Points
    4 047
    Par défaut
    Re,

    Alors là !!!

    Je n'ai trouve dans MSDN que la fonction Timer, mais je ne sais pas si cela pourra t'aider ?

    Encore un peu de patois ...

    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
     
    Microsoft® Visual Basic® Scripting Edition
    Timer Function   Language Reference 
    Version 5 
     
     
    See Also 
     
     
    --------------------------------------------------------------------------------
     
    Description
    Returns the number of seconds that have elapsed since 12:00 AM (midnight).
    Syntax
    Timer
     
    Remarks
    The following example uses the Timer function to determine the time it takes to iterate a For...Next loop N times: 
    Function TimeIt(N)
      Dim StartTime, EndTime
      StartTime = Timer
      For I = 1 To N
      Next
      EndTime = Timer
      TimeIt = EndTime - StartTime
    End Function

  11. #11
    Membre à l'essai
    Inscrit en
    Janvier 2004
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    merci à tous je vais essayer tout d'abord ce script en vba ...
    je voudrai avoir une petite aide concernant ce script :
    comment faire en sorte (l application tournant continuellement) d'avoir ma condition effectuée journalièrement ?

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    Dim heure_mail
    Dim MyTime
    heure_mail = 5
     
    MyTime = hour(Time)
        If heure_mail = MyTime Then
            ret = Shell("C:\Program Files\Claris Corp\FileMaker Pro 4.0\FileMaker Pro.exe c:\mail.fp3", vbNormalFocus)
        end if

  12. #12
    Membre à l'essai
    Inscrit en
    Janvier 2004
    Messages
    13
    Détails du profil
    Informations forums :
    Inscription : Janvier 2004
    Messages : 13
    Points : 10
    Points
    10
    Par défaut
    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
     
    Private Sub UserForm_Initialize()
     
    Dim effectuer As Boolean
    Dim heure_mail
    Dim MyTime
    Dim debut
    Dim laps_time
    heure_mail = 5
     
    laps_time = 86400
     
    debut = Timer
    Do While Timer < debut + laps_time
    MyTime = hour&#40;Time&#41;
    If heure_mail = MyTime Then
            ret = Shell&#40;"C&#58;\Program Files\Claris Corp\FileMaker Pro 4.0\FileMaker Pro.exe c&#58;\mail.fp3", vbNormalFocus&#41;
    End If
    Loop
     
    End Sub
    voila un exemple qui hélas ne fonctionne que pour une journée....comment faire pour que l'application fonctionne continuellement ?

  13. #13
    Membre du Club Avatar de Prue
    Profil pro
    Inscrit en
    Juillet 2003
    Messages
    101
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Juillet 2003
    Messages : 101
    Points : 59
    Points
    59
    Par défaut
    Bonjour à tous!

    Excusez-moi de vous déranger mais j'ai voulu me servir de ça
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Set WshShell = WScript.CreateObject&#40;"WScript.Shell"&#41; 
    WshShell.Run &#40;"%windir%\notepad" & WScript.ScriptFullName&#41;
    mais mon navigateur ne semble pas trés d'accord
    Objet requis: 'WScript'
    C'est la première ligne qui pose un problème d'aprés lui.

    Quelqu'un a une idée ?

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

Discussions similaires

  1. vbs lancer programme a distance avec retour
    Par christ29 dans le forum VBScript
    Réponses: 0
    Dernier message: 22/11/2010, 10h35
  2. vbs lancer un programme a distance
    Par christ29 dans le forum VBScript
    Réponses: 1
    Dernier message: 17/11/2010, 12h52
  3. [VBS] Lancer plusieurs script dans le même interpréteur
    Par intrud3r dans le forum VBScript
    Réponses: 4
    Dernier message: 12/07/2006, 16h26
  4. [VBS]Lancer un .exe
    Par eown dans le forum VBScript
    Réponses: 1
    Dernier message: 20/04/2006, 16h40
  5. [VBS] appel d'un script VBS dans un autre script VBS???
    Par Amandine62 dans le forum VBScript
    Réponses: 9
    Dernier message: 31/01/2006, 19h17

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