Executer un fichier avec un parametre en plus!

Résolu
DraaFil Messages postés 264 Date d'inscription mercredi 16 avril 2003 Statut Membre Dernière intervention 23 mars 2012 - 5 sept. 2007 à 00:19
cs_Chatbour Messages postés 764 Date d'inscription jeudi 27 juillet 2006 Statut Membre Dernière intervention 6 septembre 2010 - 5 sept. 2007 à 01:22
Bonjour à tous,

J'ai trouver un code sur le site (je ne sais pu de qui) et il excute bien mon fichier, mais j'aurais besoin de lui passer un parametre (ex: allo.exe /S).

Est-ce que quelqu'un pourrais me dire comment faire pour que cela fonctionne correctement. Merci!

code:
Form : 
 Private Sub Form_Load()
    ExecCmd App.Path & "\Wallpapers.exe /s" Marche pas
    MsgBox "Programme fermé"
    End
End Sub

Module :Public Function ExecCmd(ByRef vsCmdLine As String, Optional ByRef vsParameters As String, Optional ByRef vsCurrentDirectory As String vbNullString, Optional ByVal vnShowCmd As Long SW_SHOW, Optional ByVal vnTimeOut As Long = 200) As Long
Dim lpShellExInfo As SHELLEXECUTEINFOA
    With lpShellExInfo
        .cbSize = Len(lpShellExInfo)
        .lpDirectory = vsCurrentDirectory
        .lpVerb = "open"
        .lpFile = vsCmdLine
        .lpParameters = vsParameters
        .nShow = vnShowCmd
        .fMask = SEE_MASK_DOENVSUBST Or SEE_MASK_NOCLOSEPROCESS Or SEE_MASK_IDLIST
    End With


    If ShellExecuteEx(lpShellExInfo) Then
        Do While WaitForSingleObject(lpShellExInfo.hProcess, vnTimeOut) = WAIT_TIMEOUT
            DoEvents
        Loop


        GetExitCodeProcess lpShellExInfo.hProcess, ExecCmd
        CloseHandle lpShellExInfo.hProcess
    Else
        ExecCmd = vbError
    End If
End Function

Merci à tous!!
DraaFil

1 réponse

cs_Chatbour Messages postés 764 Date d'inscription jeudi 27 juillet 2006 Statut Membre Dernière intervention 6 septembre 2010 19
5 sept. 2007 à 01:22
Salut,

j'ai pas testé le code, mais je vous invite à essayer
en changeant la ligne :


ExecCmd App.Path & "\Wallpapers.exe /s" Marche pas




par la ligne :




ExecCmd App.Path & "\Wallpapers.exe", "/s"
'pourvu que ça marche ; )
3
Rejoignez-nous