Fermeture application simple

cs_Oasis3000 Messages postés 3 Date d'inscription vendredi 30 juillet 2004 Statut Membre Dernière intervention 6 avril 2006 - 6 avril 2006 à 17:01
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 - 7 avril 2006 à 00:04
Bonjour,

J'ai besoin de scripter l'installation d'une app non scriptable 0_o
Je vais donc le faire par touche clavier
Mais pour cela j'ai besoin d'ouvrir une appli et de la fermer ensuite

Mon script ressemble à ça :

'mise en place
Set WshShell = WScript.CreateObject("WScript.Shell")

'selection setup
WshShell.Run app & "notepad.exe"

[..]

'Et ICI je veux fermer notepad.exe


/////
Mais je suis un peu perdu entre VBA vb.net ... j'ai essayé pas mal des solutions proposée via la recherche "fermeture app" "kill process" mais sans succès.

2 réponses

ta4444 Messages postés 36 Date d'inscription vendredi 17 mars 2006 Statut Membre Dernière intervention 6 novembre 2006
6 avril 2006 à 18:02
Si tu n'as pas d'autre notepad ouvert (que tu ne voudrais pas fermer), j'ai une solution radicale :

Public Function KillProcess(ByVal ProcessName As String) As Boolean
Dim svc As Object
Dim sQuery As String
Dim oproc
Set svc = GetObject("winmgmts:root\cimv2")
sQuery = "select * from win32_process where name='" & ProcessName & "'"
For Each oproc In svc.execquery(sQuery)
oproc.Terminate
Next
Set svc = Nothing
End Function

Call KillProcess ("notepad.exe")
0
cs_JMO Messages postés 1854 Date d'inscription jeudi 23 mai 2002 Statut Membre Dernière intervention 24 juin 2018 27
7 avril 2006 à 00:04
Bonsoir,

Dans le même principe:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run app & "%SystemRoot%\system32\notepad.exe"
WScript.Sleep(200)
WshShell.SendKeys "nous sommes sur le forum de VBF"
WScript.Sleep(1000)
WshShell.SendKeys "%(fqn)" 'correspond à Alt + F(fichier) + Q(quitter) + "voulez-vs enregister"N(non)
Set WshShell = Nothing
MsgBox "Le process NotePad.exe est bien fermé"

jean-marc
0
Rejoignez-nous