Jump to content

Kill excel.exe every 1 min


 Share

Go to solution Solved by SolarFox,

Recommended Posts

Got some small machine that log some parameters in excel ( old XLS format) and i have few peoples here who open that excel just to see parameters but no one changing anything and if they left excel open and go away machine won`t log any more because file is locked until excel is closed.

Link to comment
Share on other sites

  • Developers

Is the logging process not using Excel as else you would likely kill the update process at some point in time?

Check the helpfile for While --- Wend to create a permanent loop around your posted code. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hi @SolarFox,

welcome to the forum 👋 .
In the first point of view it looks like a "prank on friends, a kind of an annoying virus" 😒 . But you explained your purpose, fine.

hi @Jos,

you were faster than me 😅 .

SolarFox, it could also be a good idea to create a exit function to leave the while loop. Just in case it doesn't work like you expect.
Have a look for HotKeySet for example.

Best regards
Sven

________________
Stay innovative!

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

🎲 AutoIt (en) Cheat Sheet

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔮 Me on GitHub

💬 Opinion about new forum sub category

📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to comment
Share on other sites

It`s not for prank. Just peoples simple forget to close excel and we need that logs to see parameters.

I check once again a little deeper. No, excel is not used when application is creating log file, it have his own engine integrated, even no office need to be installed on that PC.

 

Link to comment
Share on other sites

44 minutes ago, SOLVE-SMART said:

@SolarFox👋😒@Jos😅olarFox, it could also be a good idea to create a exit function to leave the while loop. Just in case it doesn't work like you expect.
Have a look for HotKeySet for example.

Best regards
Sven

________________
Stay innovative!

I compiled exe file, that`s more than fine. There is exit button in tray if we don`t need to run it forever.

Link to comment
Share on other sites

23 minutes ago, SolarFox said:

Thanx, It`s working.

As an extension you could add the suggestion from @SOLVE-SMART  :

1 hour ago, SOLVE-SMART said:

it could also be a good idea to create a exit function to leave the while loop.

 

HotKeySet("{ESC}", "_Terminate") ; Escape

While True
    Sleep(60000)
    If ProcessExists("excel.exe") Then
        ProcessClose("excel.exe")
    EndIf
WEnd

Func _Terminate()
    Exit
EndFunc

@SolarFox Edit : Or

HotKeySet("{ESC}", "_Terminate") ; Escape

While True
    Sleep(60000)
    If ProcessExists("excel.exe") Then
        ProcessClose("excel.exe")
    EndIf
WEnd

Func _Terminate()
    If ProcessExists("excel.exe") Then ProcessClose("excel.exe")
    Exit
EndFunc

 

Edited by Musashi
typo

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

I suggest to use the Excel UDF to close Excel.

#include <Excel.au3>

HotKeySet("{ESC}", "_Terminate") ; Escape
Global $oExcel
While True
    Sleep(60000)
    If ProcessExists("excel.exe") Then
        $oExcel = _Excel_Open() ; Connect to the running Excel instance
        ; Close the Excel instance without saving open workbooks and force close the insance even when it is not created by _Excel_Open
        _Excel_Close($oExcel, False, True)
    EndIf
WEnd

Func _Terminate()
    If ProcessExists("excel.exe") Then
        $oExcel = _Excel_Open() ; Connect to the running Excel instance
        ; Close the Excel instance without saving open workbooks and force close the insance even when it is not created by _Excel_Open
        _Excel_Close($oExcel, False, True)
    EndIf
    Exit
EndFunc

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...