Creating a "cleanup script"

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
Mitch
Newbie
Posts: 9
Joined: Wed Apr 22, 2020 9:13 pm

Creating a "cleanup script"

Post by Mitch » Tue May 26, 2020 8:50 pm

My scripts open browser windows, download files, open them in excel, saves them as ____-, and when everything works correctly, it closes all the windows as it goes.

On occasion, something goes wrong and one of the windows will remain open. While I know I can create scripts with specific steps for each window name that might be open, I'm hoping to find something that "cleans up" with a wider brush stroke.

Is there a "select any excel/chrome window that is open by any name" or similar function?
My desire is to close all Excel, Chrome, and eventually a few windows from within our accounting system.

Thanks
The Perpetual Newb

Mitch
Newbie
Posts: 9
Joined: Wed Apr 22, 2020 9:13 pm

Re: Creating a "cleanup script"

Post by Mitch » Tue May 26, 2020 9:11 pm

ok... so GetWindowList can generate a list of open windows....

I guess I'll attempt to loop through the list and clean up from there (unless any better suggestions come though in the meantime)

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Creating a "cleanup script"

Post by JRL » Tue May 26, 2020 9:46 pm

Might be easier to use Killprocess> to kill all Chrome.exe and Excel.exe processes. Or, I like to use DOS taskkill. Taskkill kills all of a given process name in one swoop.

Code: Select all

Let>RP_Wait=1
Let>RP_Windowmode=0
RunProcess>cmd /c taskkill /im "excel.exe" /f
RunProcess>cmd /c taskkill /im "chrome.exe" /f

Mitch
Newbie
Posts: 9
Joined: Wed Apr 22, 2020 9:13 pm

Re: Creating a "cleanup script"

Post by Mitch » Wed May 27, 2020 7:33 pm

So clean. So nice. So appreciated. :) Thank you!!!!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts