Jump to content

Close Office Process


Recommended Posts

Hello

Sorry bu advance for my english.

I want a process who detect and close all office process (like winword.exe, excel.exe, etc.....). I made a gui who call user to close winword but i want a gui who call user for all process.

Is it clear ?

this is my script :

#include <GUIConstants.au3>

Break(1)

;Copie des fichiers
    FileInstall("Exemple.jpg", "F:\Exemple.jpg", 1)

If ProcessExists("winword.exe") Then
    $m1 = "------ INFORMATIQUE ------"
    $m2 = "Une mise à jour de ""Exemple"" est nécessaire sur votre ordinateur."
    $m3 = "Si vous êtes en train de travailler sous ""Exemple"","
    $m4 = "Merci de fermer cette application."
    $m5 = "Dans le cas contraire et à la fin du temps imparti,"
    $m6 = """Exemple"" sera automatiquement fermé"
    $m7 = "Temps imparti"
    GUICreate("Exemple update", 350, 250, -1, -1,   $WS_POPUPWINDOW)
    GUICtrlCreatePic("F:\Exemple.jpg", -1, -1, 110, 36)

    $label1 = GUICtrlCreateLabel($m1, 40, 50, 280, 20, $SS_CENTER)
    $label2 = GUICtrlCreateLabel($m2, 10, 70, 330, 20, $SS_CENTER)
    $label3 = GUICtrlCreateLabel($m3, 10, 100, 330, 20, $SS_CENTER)
    $label4 = GUICtrlCreateLabel($m4, 10, 120, 330, 20, $SS_CENTER)
    $label5 = GUICtrlCreateLabel($m5, 10, 150, 330, 20, $SS_CENTER)
    $label6 = GUICtrlCreateLabel($m6, 10, 170, 330, 20, $SS_CENTER)
    $label7 = GUICtrlCreateLabel($m7, 10, 230, 330, 20, $SS_CENTER)
    GUISetState()
    $wait = 200; wait ms for next progressstep
    $s = 0; progressbar-saveposition
    $Progressbar = GUICtrlCreateProgress(20, 200, 305, 20)
    GUICtrlSetColor($Progressbar,0x00CC00)
    $msg = GUIGetMsg()
    For $i = $s To 100
    If ProcessExists("winword.exe") = 0 then ExitLoop
    If GUICtrlRead($Progressbar) = 65 Then
    GUICtrlSetColor($Progressbar,0xff0000)
    TrayTip("Exemple update", "10 secondes avant la fermeture de ""Exemple""", 10, 1)
    EndIf
        $s = $i
        $s=0
      GUICtrlSetData ($Progressbar,$i)
      Sleep($wait)
  Next 
  
  ;loop pour le process en multiples utilisations
  Do
    ProcessClose("winword.exe")
Until Not ProcessExists("winword.exe")
  EndIf
  Opt("TrayIconHide", 1)
    FileDelete("F:\Exemple.jpg")
  GUIDelete()

Thanks for help

Link to comment
Share on other sites

A command like this but it doesn't work :

If ProcessExists("winword.exe") or if ProcessExists("excel.exe") Then

$m1 = "------ INFORMATIQUE ------"

$m2 = "Une mise à jour de ""Exemple"" est nécessaire sur votre ordinateur."

$m3 = "Si vous êtes en train de travailler sous ""Exemple"","

Link to comment
Share on other sites

Stop searching, i write this and it's works very well :

#include <GUIConstants.au3>
Break(1)

;Copie du logo
FileInstall("Office.jpg", "D:\Office.jpg", 1)

;Variables processus
$word = ProcessExists("winword.exe")
$excel = ProcessExists("excel.exe")
$powerpoint = ProcessExists("powerpnt.exe")
$access = ProcessExists("msaccess.exe")
$outlook = ProcessExists("outlook.exe")
$publisher = ProcessExists("mspub.exe")


If $excel or $word or $powerpoint or $access Or $outlook Or $publisher Then
    $m1 = "------ INFORMATIQUE ------"
    $m2 = "Une mise à jour ""OFFICE 2003"" est nécessaire sur votre ordinateur."
    $m3 = "Si vous êtes en train de travailler sur :"
    $m4 = "Word, Excel, PowerPoint, Access, Publisher ou Outlook,"
    $m5 = "Merci de fermer ces applications."
    $m6 = "Dans le cas contraire et à la fin du temps imparti,"
    $m7 = "ces applications seront automatiquement fermées"
    $m8 = "Temps imparti"
    GUICreate("Office update", 350, 300, -1, -1,   $WS_POPUPWINDOW)
    GUICtrlCreatePic("D:\Office.jpg", 155, 5, 40, 40)
    $label1 = GUICtrlCreateLabel($m1, 40, 50, 280, 20, $SS_CENTER)
    $label2 = GUICtrlCreateLabel($m2, 10, 70, 330, 20, $SS_CENTER)
    $label3 = GUICtrlCreateLabel($m3, 10, 100, 330, 20, $SS_CENTER)
    $label4 = GUICtrlCreateLabel($m4, 10, 120, 330, 20, $SS_CENTER)
    $label5 = GUICtrlCreateLabel($m5, 10, 140, 330, 20, $SS_CENTER)
    $label6 = GUICtrlCreateLabel($m6, 10, 170, 330, 20, $SS_CENTER)
    $label7 = GUICtrlCreateLabel($m7, 10, 190, 330, 20, $SS_CENTER)
    $label8 = GUICtrlCreateLabel($m8, 10, 230, 330, 20, $SS_CENTER)
    GUISetState()
    $wait = 200; wait ms for next progressstep
    $s = 0; progressbar-saveposition
    $Progressbar = GUICtrlCreateProgress(20, 250, 305, 20)
    GUICtrlSetColor($Progressbar,0x00CC00)
    $msg = GUIGetMsg()
    For $i = $s To 100
    ;If $excel = 0 then ExitLoop
    If ProcessExists($excel) = 0 and ProcessExists("winword.exe") = 0 And ProcessExists("powerpnt.exe") = 0 And ProcessExists("msaccess.exe") = 0 And ProcessExists("outlook.exe") = 0 And ProcessExists("mspub.exe") = 0 then ExitLoop
    
    If GUICtrlRead($Progressbar) = 65 Then
    GUICtrlSetColor($Progressbar,0xff0000)
    TrayTip("Office update", "10 secondes avant la fermeture de la suite Office", 10, 1)
    EndIf
        $s = $i
        $s=0
      GUICtrlSetData ($Progressbar,$i)
      Sleep($wait)
  Next
 
  ;loop pour le process en multiples utilisations
  Do
    ProcessClose($word)
    ProcessClose($excel)
    ProcessClose($powerpoint)
    ProcessClose($access)
    ProcessClose($outlook)
    ProcessClose($publisher)
Until Not ProcessExists($word)
          ProcessExists($excel)
          ProcessExists($powerpoint)
          ProcessExists($access)
          ProcessExists($outlook)
          ProcessExists($publisher)

  EndIf
  Opt("TrayIconHide", 1)
    FileDelete("D:\Office.jpg")
  GUIDelete()

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...