OVH Cloud OVH Cloud

execution d'une installation

4 réponses
Avatar
gilles
Bonjour je cherche a executer des installations automatisé de logiciel.
Jusqu'a present mon programme passait par une fenetre dos je souhaite changer
de methode et je ne sais pas quel instruction utiliser
exemple:
if case_a_cocher.value=1 then
(instruction recherché) \\chemin réseau\fichier a executer
end if

4 réponses

Avatar
ng
Salut,

Regarde du coté de Shell() dans la doc.

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

gilles wrote:
Bonjour je cherche a executer des installations automatisé de
logiciel. Jusqu'a present mon programme passait par une fenetre dos
je souhaite changer de methode et je ne sais pas quel instruction
utiliser
exemple:
if case_a_cocher.value=1 then
(instruction recherché) chemin réseaufichier a executer
end if


Avatar
gilles
Merci ca marche par contre j ai plus de temporisation entre les installation,
je sais pas dans ce cas si je peu utilisé des boucles. Du style, tant que ta
pas finit cette install tu attends sagement. Et des quel a finit tu passe a
la suivante
k es ce ke tu en pense ?

"ng" wrote:

Salut,

Regarde du coté de Shell() dans la doc.

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

gilles wrote:
> Bonjour je cherche a executer des installations automatisé de
> logiciel. Jusqu'a present mon programme passait par une fenetre dos
> je souhaite changer de methode et je ne sais pas quel instruction
> utiliser
> exemple:
> if case_a_cocher.value=1 then
> (instruction recherché) chemin réseaufichier a executer
> end if





Avatar
ng
Salut,

Colle ceci dans un module :

Option Explicit

Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle
As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal
bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment
As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO,
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long

Public Function ShellAndWait(ByVal strCmd As String, Optional ByVal
lMaxMiliSec As Long = -1&) As Boolean
Dim tProc As PROCESS_INFORMATION, tStartInf As STARTUPINFO
tStartInf.cb = Len(tStartInf)
If (CreateProcessA(0&, strCmd, 0&, 0&, 1&, &H20&, 0&, 0&, tStartInf,
tProc) <> 0) Then '//NORMAL_PRIORITY_CLASS
Call WaitForSingleObject(tProc.hProcess, lMaxMiliSec) '//INFINITE
pour -1&
Call CloseHandle(tProc.hProcess)
ShellAndWait = True
End If
End Function



Utilisation :
Call ShellAndWait("notepad", 5000) '//Attends notepad au maximum 5 secondes
Call ShellAndWait("calc") '//Attends calc jusqu'à la fermeture

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

gilles wrote:
Merci ca marche par contre j ai plus de temporisation entre les
installation, je sais pas dans ce cas si je peu utilisé des boucles.
Du style, tant que ta pas finit cette install tu attends sagement. Et
des quel a finit tu passe a la suivante
k es ce ke tu en pense ?

"ng" wrote:

Salut,

Regarde du coté de Shell() dans la doc.

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

gilles wrote:
Bonjour je cherche a executer des installations automatisé de
logiciel. Jusqu'a present mon programme passait par une fenetre dos
je souhaite changer de methode et je ne sais pas quel instruction
utiliser
exemple:
if case_a_cocher.value=1 then
(instruction recherché) chemin réseaufichier a executer
end if






Avatar
gilles
merci bcp bonne fetes

"ng" wrote:

Salut,

Colle ceci dans un module :

Option Explicit

Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type

Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type

Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle
As Long, ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal
lpApplicationName As Long, ByVal lpCommandLine As String, ByVal
lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal
bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment
As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO,
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long)
As Long

Public Function ShellAndWait(ByVal strCmd As String, Optional ByVal
lMaxMiliSec As Long = -1&) As Boolean
Dim tProc As PROCESS_INFORMATION, tStartInf As STARTUPINFO
tStartInf.cb = Len(tStartInf)
If (CreateProcessA(0&, strCmd, 0&, 0&, 1&, &H20&, 0&, 0&, tStartInf,
tProc) <> 0) Then '//NORMAL_PRIORITY_CLASS
Call WaitForSingleObject(tProc.hProcess, lMaxMiliSec) '//INFINITE
pour -1&
Call CloseHandle(tProc.hProcess)
ShellAndWait = True
End If
End Function



Utilisation :
Call ShellAndWait("notepad", 5000) '//Attends notepad au maximum 5 secondes
Call ShellAndWait("calc") '//Attends calc jusqu'à la fermeture

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

gilles wrote:
> Merci ca marche par contre j ai plus de temporisation entre les
> installation, je sais pas dans ce cas si je peu utilisé des boucles.
> Du style, tant que ta pas finit cette install tu attends sagement. Et
> des quel a finit tu passe a la suivante
> k es ce ke tu en pense ?
>
> "ng" wrote:
>
>> Salut,
>>
>> Regarde du coté de Shell() dans la doc.
>>
>> --
>> Nicolas G.
>> FAQ VB : http://faq.vb.free.fr
>> API Guide : http://www.allapi.net
>> Google Groups : http://groups.google.fr/
>> MZ-Tools : http://www.mztools.com/
>>
>> gilles wrote:
>>> Bonjour je cherche a executer des installations automatisé de
>>> logiciel. Jusqu'a present mon programme passait par une fenetre dos
>>> je souhaite changer de methode et je ne sais pas quel instruction
>>> utiliser
>>> exemple:
>>> if case_a_cocher.value=1 then
>>> (instruction recherché) chemin réseaufichier a executer
>>> end if