OVH Cloud OVH Cloud

commande pour fermer une fenetre

6 réponses
Avatar
gilles
Bonjour
D avance je vous previens que je suis plus que debutant en vb.
Je recherche une fonction pour fermer une fenetre c est a dire:
je suis entraint de creer un petit programme pour installée des logiciels et
des mises a jour dont le service pack 3 de office xp. M/ais celui ci fait
apparaitre une fenetre de fin d installation et je voudrais donc savoir
comment enlevé automatiquement cette fenetre
Merci d avance pour votre aide

6 réponses

Avatar
YannX
"gilles" a écrit dans le message de
news:
Bonjour
D avance je vous previens que je suis plus que debutant en vb.
Je recherche une fonction pour fermer une fenetre c est a dire:
je suis entraint de creer un petit programme pour installée des logiciels


et
des mises a jour dont le service pack 3 de office xp. M/ais celui ci fait
apparaitre une fenetre de fin d installation et je voudrais donc savoir
comment enlevé automatiquement cette fenetre


Bnjr,
Je ne suis pas expert au point de pondre la réponse on-line,
mais je vais effleurer le principe que je crois comprendre,
puis rajouter quelques pistes (articles de FAQ approchés).

D'abord, une fenetre s'identifie par un Handle (un nombre du système).
Pour la reconnaitre, soit elle fait partie de l'application courante (ecrite
en VB) -cas 1°-,
soit il faut aller la rechercher par son titre en parcourant la liste des
fenetres....
(pour cela s'inspirer de Romain Puyfoulhoux (
http://vb.developpez.com/faq/?page=Divers#singleton ).

Ensuite, " il ne reste plus que " à la fermer, soit par un Form.Hide ou
Unload dans le cas 1°,
soit on doit -je crois bien- fermer l'application (SysCommand Kill ....)

Esperant aider......et suivre des explciations plus precises.

Y@+
Avatar
gilles
"YannX" wrote:


"gilles" a écrit dans le message de
news:
> Bonjour
> D avance je vous previens que je suis plus que debutant en vb.
> Je recherche une fonction pour fermer une fenetre c est a dire:
> je suis entraint de creer un petit programme pour installée des logiciels
et
> des mises a jour dont le service pack 3 de office xp. M/ais celui ci fait
> apparaitre une fenetre de fin d installation et je voudrais donc savoir
> comment enlevé automatiquement cette fenetre
Bnjr,
Je ne suis pas expert au point de pondre la réponse on-line,
mais je vais effleurer le principe que je crois comprendre,
puis rajouter quelques pistes (articles de FAQ approchés).

D'abord, une fenetre s'identifie par un Handle (un nombre du système).
Pour la reconnaitre, soit elle fait partie de l'application courante (ecrite
en VB) -cas 1°-,
soit il faut aller la rechercher par son titre en parcourant la liste des
fenetres....
(pour cela s'inspirer de Romain Puyfoulhoux (
http://vb.developpez.com/faq/?page=Divers#singleton ).

Ensuite, " il ne reste plus que " à la fermer, soit par un Form.Hide ou
Unload dans le cas 1°,
soit on doit -je crois bien- fermer l'application (SysCommand Kill ....)

Esperant aider......et suivre des explciations plus precises.

Y@+

C'est une fenetre comme tu la nomme que je ne controle pas elle fait partie du programme de la mise a jour du service pack 3 de office xp donc je ne vois pas comment je peu connaitre le nom de la fenetre a part peut etre dans la liste des processus actifs a se moment ?



Avatar
YannX
Bnjr,

Je pensais bien..... donc il faut utiliser la technique indiquée dans
l'astuce de la FAQ,
en faisant rechercher la fenetre par le "titre" affiché, de la mème façon
que tu l'identifies a la lecture du titre...

Puisque tu peux déjà exécuter le programme a fermer sans ton programme, tu
peux reconnaitre le libellé titre :
idée => ecris un petit programme qui lit le titre a rechercher en paramètre
dans un fichier .INI
(tu trouveras sur une FAQ ou sur vbfrance.com une classe toute faite pour
lire un fichier texte .INI)
Quand ce petit programme fonctionnera, tu etudieras commencer trouver
l'exécutable correspondant....
Y@+
"gilles" a écrit dans le message de
news:


"YannX" wrote:

>
> "gilles" a écrit dans le message de
> news:
> > Bonjour
> > D avance je vous previens que je suis plus que debutant en vb.
> > Je recherche une fonction pour fermer une fenetre c est a dire:
> > je suis entraint de creer un petit programme pour installée des


logiciels
> et
> > des mises a jour dont le service pack 3 de office xp. M/ais celui ci


fait
> > apparaitre une fenetre de fin d installation et je voudrais donc


savoir
> > comment enlevé automatiquement cette fenetre
> Bnjr,
> Je ne suis pas expert au point de pondre la réponse on-line,
> mais je vais effleurer le principe que je crois comprendre,
> puis rajouter quelques pistes (articles de FAQ approchés).
>
> D'abord, une fenetre s'identifie par un Handle (un nombre du système).
> Pour la reconnaitre, soit elle fait partie de l'application courante


(ecrite
> en VB) -cas 1°-,
> soit il faut aller la rechercher par son titre en parcourant la liste


des
> fenetres....
> (pour cela s'inspirer de Romain Puyfoulhoux (
> http://vb.developpez.com/faq/?page=Divers#singleton ).
>
> Ensuite, " il ne reste plus que " à la fermer, soit par un Form.Hide ou
> Unload dans le cas 1°,
> soit on doit -je crois bien- fermer l'application (SysCommand Kill ....)
>
> Esperant aider......et suivre des explciations plus precises.
>
> Y@+
>
> C'est une fenetre comme tu la nomme que je ne controle pas elle fait


partie du programme de la mise a jour du service pack 3 de office xp donc je
ne vois pas comment je peu connaitre le nom de la fenetre a part peut etre
dans la liste des processus actifs a se moment ?
>


Avatar
LE TROLL
Salut, tu commences fort, voici, ça pourrait marcher :o)

' form1 tous les handles
'
Private Declare Function GetForegroundWindow Lib "user32" () As Long
'hwnd (handle de la forme)
'
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA"
_
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As
Long
'
Private Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
'
Private Declare Function TerminateProcess Lib "kernel32" ( _
ByVal hProcess As Long, _
ByVal uExitCode As Long _
) As Long
'
Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long
'
Private Const PROCESS_TERMINATE = &H1
Dim NumProcess As Long
Dim RC As Long
Dim hProcess As Long

Sub Form_Load() ' LIST1 + TEXT1
Dim hwnd
'
List1.Clear
GetWindowsList
'
' handle de cette form
hwnd = GetForegroundWindow
NumProcess = hwnd
Text1 = "Handle en cours : " & hwnd
'''''''''''''
' quand handle repéré en le cherchant dans la liste,
' débrancher sur fermeture du handle
Call fermer
End Sub

Sub fermer()
hProcess = OpenProcess(PROCESS_TERMINATE, -1&, NumProcess)
RC = TerminateProcess(hProcess, 0&)
RC = CloseHandle(hProcess)
End Sub

Private Function EnumWindowsProc(ByVal lgHwnd As Long, ByVal lgParam As
Long) As Long
Dim stTmp As String, lgTmp As Long, lgRet As Long
'
stTmp = Space$(120)
lgTmp = 119
lgRet = GetWindowText(lgHwnd, stTmp, lgTmp)
If Len(stTmp) > 1 And lgRet <> 0 Then
Form1.List1.AddItem Format(lgHwnd, "00000000") & " : " & stTmp
End If
EnumWindowsProc = 1
End Function
'---------------------------------------

MODULE

Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA"
_
(ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As
Long
'
Public Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
'


Public Function GetWindowsList()
Dim lgRep As Long
'
stGetWindowsList = vbNullString
lgRep = EnumWindows(AddressOf EnumWindowsProc, 0)
End Function


Public Function EnumWindowsProc(ByVal lgHwnd As Long, ByVal lgParam As Long)
As Long
Dim stTmp As String, lgTmp As Long, lgRet As Long
'
stTmp = Space$(120)
lgTmp = 119
lgRet = GetWindowText(lgHwnd, stTmp, lgTmp)
If Len(stTmp) > 1 And lgRet <> 0 Then
Form1.List1.AddItem Format(lgHwnd, "00000000") & " : " & stTmp
End If
EnumWindowsProc = 1
End Function
Avatar
gilles
Hi tu dits que je commence fort arf c est un programme tous simple a mon avis
mais le tiens j y comprends rien et il ne marche pas arf
voici le programme que j ai amélioré
mon probleme se situe au niveau du officexpsp3.value
apres la tempo je veux juste une petite fonction pour fermer cette fenetre
ou sinon des belle explication pour debutant desolé je suis grave mauvais en
programmation


Private Sub Command1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createTextFile("c:tempinstall.bat", True)
If compagnie = "" Then
compagnie = "GROUPE MEUNIER"
End If
If nom_personne = "" Then
nom_personne = "Administrateur"
End If
a.writeline ("@echo off")
a.writeline ("")
a.writeline ("echo démarrage des installations")
a.writeline ("if not exist C:winnt goto suite_windows_installer")
a.writeline ("start /wait
L:installationWindows_Installer_2.0InstMsiW.exe /Q")
a.writeline (":suite_windows_installer")
If OfficeXPStandard.Value Then
a.writeline ("")
a.writeline ("echo installation de office XP standard")
a.writeline ("start /wait L:installationofficexpinstall.exe
TRANSFORMS=""L:installationofficexpOffice XP normal.MST"" COMPANYNAME="""
& compagnie & """ USERNAME=""" & nom_personne & """ /qb-")
a.writeline ("copy ""L:installationraccourcisMicrosoft Word.lnk""
""c:Documents and settingsall usersbureauMicrosoft Word.lnk""")
a.writeline ("copy ""L:installationraccourcisMicrosoft
Excel.lnk"" ""c:Documents and settingsall usersbureauMicrosoft
Excel.lnk""")
a.writeline ("copy ""L:installationraccourcisMicrosoft
PowerPoint.lnk"" ""c:Documents and settingsall usersbureauMicrosoft
PowerPoint.lnk""")
a.writeline ("echo installation office XP standard terminée >>
c:tempinstallation.log")
End If
If OfficeXPSP3.Value Then
a.writeline ("")
a.writeline ("echo installation du SP3 pour office XP")
a.writeline ("start /wait L:Pack_officexpOfficeXpSp3.exe -q")
a.writeline ("echo installation service pack 3 office XP standard
terminée >> c:tempinstallation.log")
End If
If Winzip8.Value Then
a.writeline ("")
a.writeline ("echo installation de winzip")
a.writeline ("xcopy /s /i L:installationwinzip ""c:program
fileswinzip""")
a.writeline ("start /wait c:progra~1winzipwinzip32.exe
/autoinstall")
'a.writeline ("copy ""L:installationraccourcisWinZip.lnk"" ""c:Documents
and settingsall usersbureauWinZip.lnk""")
a.writeline ("echo installation winzip terminée >>
c:tempinstallation.log")
End If
If Acrobat6.Value Then
a.writeline ("")
a.writeline ("echo installation de acrobat reader 6")
a.writeline ("start L:Acrobat-ReaderVersion-6FRABIGsetup.exe /s
/v/qb-")
a.writeline ("L:installationwait.exe 150")
a.writeline ("echo installation acrobat reader 6 terminée >>
c:tempinstallation.log")
End If
If Reflection_13.Value Then
a.writeline ("")
a.writeline ("echo installation de reflection 9.0")
a.writeline ("start /wait msiexec /i L:ReflectionV9.0UD900ILC.msi
/qn")
a.writeline ("L:installationwait.exe 400")
a.writeline ("copy ""L:reflectiongpaoSettings.r2w"" ""c:program
filesreflectionSettings.r2w""")
a.writeline ("copy ""L:installationraccourcisGPAO -
Reflection.lnk"" ""c:Documents and settingsall usersbureauGPAO -
Reflection.lnk""")
a.writeline ("echo installation reflection 9.0 terminée >>
c:tempinstallation.log")
End If
If reflection_1.Value Then
a.writeline ("")
a.writeline ("echo installation de reflection 9.0")
a.writeline ("start /wait msiexec /i L:ReflectionV9.0UD900ILC.msi
/qn")
a.writeline ("L:installationwait.exe 400")
a.writeline ("copy ""L:ReflectionGpaomeunierSettings.r2w""
""c:program filesreflectionSettings.r2w""")
a.writeline ("copy ""L:installationraccourcisGPAO -
Reflection.lnk"" ""c:Documents and settingsall usersbureauGPAO -
Reflection.lnk""")
a.writeline ("echo installation reflection 9.0 terminée >>
c:tempinstallation.log")
End If
If PCDuo8_5.Value Then
a.writeline ("")
a.writeline ("echo installation de PC Duo 8.50")
a.writeline ("start /wait L:Pc_DuoV8.50setup.exe -s")
a.writeline ("L:installationwait.exe 60")
a.writeline ("echo installation pc duo 8.50 terminée >>
c:tempinstallation.log")
End If
If Lotus6_51.Value Then
a.writeline ("")
a.writeline ("echo installation de Lotus notes 6.51")
a.writeline ("start /wait msiexec /i
L:notes_clientClient-651clientsW32IntelLotusNotes651fr.msi /qn")
a.writeline ("L:installationwait.exe 300")
a.writeline ("echo installation lotus notes 6.51 terminée >>
c:tempinstallation.log")
End If
If Voloview.Value Then
a.writeline ("")
a.writeline ("echo installation de VoloView")
a.writeline ("start /wait msiexec.exe /i
L:installationvolovoloviewexpress.msi ACAD_SILENT_LICENSE=YES /qb!")
a.writeline ("L:installationwait.exe 100")
a.writeline ("echo installation voloview terminée >>
c:tempinstallation.log")
End If
If IPASS Then
a.writeline ("")
a.writeline ("echo installation de Ipass")
a.writeline ("start /wait L:ipassOleane_iPC_v230_540.exe")
a.writeline ("L:installationwait.exe 100")
a.writeline ("echo installation Ipass terminée >>
c:tempinstallation.log")
End If
If windows2000_patch4 Then
a.writeline ("")
a.writeline ("if not exist C:winnt goto suite_pack4_windows_2000")
a.writeline ("start /wait
L:Correctifswin2000win2000_correctifs.bat")
a.writeline (":suite_pack4_windows_2000")
a.writeline ("echo installation windows 2000 service pack 4 terminée
c:tempinstallation.log")




End If
If correctifs_windows_xp Then
a.writeline ("")
Dim nextLine, path As String
path = "L:CorrectifswinXpinstal.bat"
Open path For Input As #1
Do Until EOF(1)
Line Input #1, nextLine
a.writeline (nextLine)
Loop
Close (1)
End If
If correctifs_windows_2000 Then
a.writeline ("")
path = "L:Correctifswin2000win2000_correctifs.bat"
Open path For Input As #1
Do Until EOF(1)
Line Input #1, nextLine
a.writeline (nextLine)
Loop
Close (1)
End If
a.writeline ("")
a.writeline ("echo installations finies : veuillez relancer le pc")
a.writeline ("")
a.writeline ("pause")
a.Close
Shell "c:tempinstall.bat"
Unload Form1




End Sub

Private Sub template_win2000_Click()
correctifs_windows_2000.Value = 1
windows2000_patch4.Value = 1
correctifs_windows_xp.Value = 0
End Sub

Private Sub template_winXP_Click()
correctifs_windows_xp.Value = 1
correctifs_windows_2000.Value = 0
windows2000_patch4.Value = 0
End Sub
Avatar
ng
Salut,

Pas de FSO en VB :) Combien de fois faudra t-il le dire lol :)

Utilise plutot les fonctions implantées : Open...

--
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:
Hi tu dits que je commence fort arf c est un programme tous simple a
mon avis mais le tiens j y comprends rien et il ne marche pas arf
voici le programme que j ai amélioré
mon probleme se situe au niveau du officexpsp3.value
apres la tempo je veux juste une petite fonction pour fermer cette
fenetre ou sinon des belle explication pour debutant desolé je suis
grave mauvais en programmation


Private Sub Command1_Click()
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.createTextFile("c:tempinstall.bat", True)
If compagnie = "" Then
compagnie = "GROUPE MEUNIER"
End If
If nom_personne = "" Then
nom_personne = "Administrateur"
End If
a.writeline ("@echo off")
a.writeline ("")
a.writeline ("echo démarrage des installations")
a.writeline ("if not exist C:winnt goto suite_windows_installer")
a.writeline ("start /wait
L:installationWindows_Installer_2.0InstMsiW.exe /Q")
a.writeline (":suite_windows_installer")
If OfficeXPStandard.Value Then
a.writeline ("")
a.writeline ("echo installation de office XP standard")
a.writeline ("start /wait L:installationofficexpinstall.exe
TRANSFORMS=""L:installationofficexpOffice XP normal.MST""
COMPANYNAME=""" & compagnie & """ USERNAME=""" & nom_personne & """
/qb-") a.writeline ("copy
""L:installationraccourcisMicrosoft Word.lnk"" ""c:Documents and
settingsall usersbureauMicrosoft Word.lnk""") a.writeline
("copy ""L:installationraccourcisMicrosoft
Excel.lnk"" ""c:Documents and settingsall usersbureauMicrosoft
Excel.lnk""")
a.writeline ("copy ""L:installationraccourcisMicrosoft
PowerPoint.lnk"" ""c:Documents and settingsall
usersbureauMicrosoft PowerPoint.lnk""")
a.writeline ("echo installation office XP standard terminée >>
c:tempinstallation.log")
End If
If OfficeXPSP3.Value Then
a.writeline ("")
a.writeline ("echo installation du SP3 pour office XP")
a.writeline ("start /wait L:Pack_officexpOfficeXpSp3.exe -q")
a.writeline ("echo installation service pack 3 office XP
standard terminée >> c:tempinstallation.log")
End If
If Winzip8.Value Then
a.writeline ("")
a.writeline ("echo installation de winzip")
a.writeline ("xcopy /s /i L:installationwinzip ""c:program
fileswinzip""")
a.writeline ("start /wait c:progra~1winzipwinzip32.exe
/autoinstall")
'a.writeline ("copy ""L:installationraccourcisWinZip.lnk""
""c:Documents and settingsall usersbureauWinZip.lnk""")
a.writeline ("echo installation winzip terminée >>
c:tempinstallation.log")
End If
If Acrobat6.Value Then
a.writeline ("")
a.writeline ("echo installation de acrobat reader 6")
a.writeline ("start
L:Acrobat-ReaderVersion-6FRABIGsetup.exe /s /v/qb-")
a.writeline ("L:installationwait.exe 150")
a.writeline ("echo installation acrobat reader 6 terminée >>
c:tempinstallation.log")
End If
If Reflection_13.Value Then
a.writeline ("")
a.writeline ("echo installation de reflection 9.0")
a.writeline ("start /wait msiexec /i
L:ReflectionV9.0UD900ILC.msi /qn")
a.writeline ("L:installationwait.exe 400")
a.writeline ("copy ""L:reflectiongpaoSettings.r2w""
""c:program filesreflectionSettings.r2w""")
a.writeline ("copy ""L:installationraccourcisGPAO -
Reflection.lnk"" ""c:Documents and settingsall usersbureauGPAO -
Reflection.lnk""")
a.writeline ("echo installation reflection 9.0 terminée >>
c:tempinstallation.log")
End If
If reflection_1.Value Then
a.writeline ("")
a.writeline ("echo installation de reflection 9.0")
a.writeline ("start /wait msiexec /i
L:ReflectionV9.0UD900ILC.msi /qn")
a.writeline ("L:installationwait.exe 400")
a.writeline ("copy ""L:ReflectionGpaomeunierSettings.r2w""
""c:program filesreflectionSettings.r2w""")
a.writeline ("copy ""L:installationraccourcisGPAO -
Reflection.lnk"" ""c:Documents and settingsall usersbureauGPAO -
Reflection.lnk""")
a.writeline ("echo installation reflection 9.0 terminée >>
c:tempinstallation.log")
End If
If PCDuo8_5.Value Then
a.writeline ("")
a.writeline ("echo installation de PC Duo 8.50")
a.writeline ("start /wait L:Pc_DuoV8.50setup.exe -s")
a.writeline ("L:installationwait.exe 60")
a.writeline ("echo installation pc duo 8.50 terminée >>
c:tempinstallation.log")
End If
If Lotus6_51.Value Then
a.writeline ("")
a.writeline ("echo installation de Lotus notes 6.51")
a.writeline ("start /wait msiexec /i
L:notes_clientClient-651clientsW32IntelLotusNotes651fr.msi /qn")
a.writeline ("L:installationwait.exe 300")
a.writeline ("echo installation lotus notes 6.51 terminée >>
c:tempinstallation.log")
End If
If Voloview.Value Then
a.writeline ("")
a.writeline ("echo installation de VoloView")
a.writeline ("start /wait msiexec.exe /i
L:installationvolovoloviewexpress.msi ACAD_SILENT_LICENSE=YES
/qb!") a.writeline ("L:installationwait.exe 100")
a.writeline ("echo installation voloview terminée >>
c:tempinstallation.log")
End If
If IPASS Then
a.writeline ("")
a.writeline ("echo installation de Ipass")
a.writeline ("start /wait L:ipassOleane_iPC_v230_540.exe")
a.writeline ("L:installationwait.exe 100")
a.writeline ("echo installation Ipass terminée >>
c:tempinstallation.log")
End If
If windows2000_patch4 Then
a.writeline ("")
a.writeline ("if not exist C:winnt goto
suite_pack4_windows_2000") a.writeline ("start /wait
L:Correctifswin2000win2000_correctifs.bat")
a.writeline (":suite_pack4_windows_2000")
a.writeline ("echo installation windows 2000 service pack 4
terminée
c:tempinstallation.log")




End If
If correctifs_windows_xp Then
a.writeline ("")
Dim nextLine, path As String
path = "L:CorrectifswinXpinstal.bat"
Open path For Input As #1
Do Until EOF(1)
Line Input #1, nextLine
a.writeline (nextLine)
Loop
Close (1)
End If
If correctifs_windows_2000 Then
a.writeline ("")
path = "L:Correctifswin2000win2000_correctifs.bat"
Open path For Input As #1
Do Until EOF(1)
Line Input #1, nextLine
a.writeline (nextLine)
Loop
Close (1)
End If
a.writeline ("")
a.writeline ("echo installations finies : veuillez relancer le pc")
a.writeline ("")
a.writeline ("pause")
a.Close
Shell "c:tempinstall.bat"
Unload Form1




End Sub

Private Sub template_win2000_Click()
correctifs_windows_2000.Value = 1
windows2000_patch4.Value = 1
correctifs_windows_xp.Value = 0
End Sub

Private Sub template_winXP_Click()
correctifs_windows_xp.Value = 1
correctifs_windows_2000.Value = 0
windows2000_patch4.Value = 0
End Sub