Saturday August 24, 2019

Quick survey on what’s coming:

  1. How to schedule any app’s launch under Windows?
  2. How to automatically close the app?
  3. If You want just to close the app’s window once the backup is done...
  4. If You want to close the app completely once the backup is done...

Many Windows apps have already backup feature built-in. There is one catch, however: an app has to be up and running in terms for its backup to be initiated. Sounds obvious; probably this has been the very reason for such a feature to exist: the assumption that an app will be indeed active all the time. But what if it’s not gonna always be that way - but You’re still in the need of being equipped with the up-to-date backup?

You could consider such a case from two alternative points of view: one, in which Your only concern will be to make the app running in case it’s not at the moment - and the other, in which Your whole PC is shut down and, therefore, it should be automatically turned on again in order to perform the backup. In this post I’ll focus on the first and much simpler scenario.

So the whole case refers to the circumstances in which You usually have Your computer turned on, but the particular app is not necessarily always launched.

How to schedule any app’s launch under Windows?

Let’s say You’ve scheduled Your app’s backup for 3 ᴘ.ᴍ. The step You need to take now is to make sure that the app will indeed be running at this particular time. In order to do so, You can use Windows' built-in tool, called Task Scheduler. It will allow You to schedule any app’s (automatic) launch, which then will be enough for it to make its job done (the backup). Here is how You could set this up (under Windows 7 - although there are high chances the thing looks similar in other Windows as well):

  1. Open the Start menu and type Task Scheduler - the first couple of letters should be enough for You to notice a Task Scheduler item on the menu - choose it.
  2. On the right side of the Task Scheduler’s window You should see Actions area, with several items to choose. Pick Create Basic Task.
  3. Name Your task (e.g., My App Backup), provide the description which could remind You on its purpose months later (a good habit) and click Next.
  4. Now, choose when exactly the task should be initiated - in our case it should take place everyday, somewhere around 3 ᴘ.ᴍ. Choose Daily and click Next.
  5. Set up the exact time - a good idea is to choose the time a couple minutes ahead of Your app’s own schedule - so, let’s say, 2:55 ᴘ.ᴍ. Then, a little below, set it to be repeated on a daily basis. Click Next.
  6. As an action choose Run a program, click Next.
  7. Click Browse, locate Your program’s executable file, select it and click Open. Once again click Next, and then, finally, Finish. You can now close the Task Scheduler window.

If You click on Task Scheduler Library, Your task should be present somewhere on the list.

How to automatically close the app?

If You do not want (or need) Your app to stay active once the backup is done - You can schedule its close, too. To do so, You need to use a simple AutoHotkey script. Before You do that, ask Yourself do You prefer to close Your app visually, or completely? As “visually” I mean just to close its window from Your desktop or taskbar (but the app may still be active under the hood) - while “complete close” force the app to be completely shut down (it won’t be running behind the scenes until You’ll launch it again).

Regardless of Your choice the first step is to install the AutoHotkey (if You haven’t done that already). Then here You are the instructions for both scenarios:

If You want just to close the app’s window once the backup is done:

  1. Open Your text editor (e.g., Notepad) and create a new text file, save it as YourName.ahk (e.g., Close-YourAppName.ahk).

  2. Copy&paste the following code into Your file:

     PostMessage, 0x112, 0xF060,,, **Xxx** ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE

The code above is similar in effect to pressing Alt+F4 or clicking the window’s close button on its title bar.
( source » )

  1. For a moment take a closer look on Your app’s window (the one You wanna close once the backup is done) - what exact title is placed on its top bar? Replace Xxx with this title (be careful - it’s case sensitive).
  2. Save the changes (CTRL+S) and close Your text editor.
  3. Right click the .ahk file You’ve just created - and choose Compile Script. In a moment You should see a new file with green icon and the same name, but different - .exe - extension.
  4. Once again perform the Task Scheduler instruction from the beginning of this article. To do so, ask Yourself what could be the max. necessary time span into which Your backup surely be fitting? Back to our example, the app itself could be set to perform the backup on 3 ᴘ.ᴍ. - suppose the backup process shouldn’t take more that 10 minutes - thus You can set the time within the Task Scheduler as 3:10 ᴘ.ᴍ..
  5. Still within Task Scheduler, as Your program (step 7) choose the newly created .exe file (with green icon).

That’s it. Now, not only Your app should be automatically initiated in case it’s not already active - but it also should be automatically closed soon after it’s not necessary for it to stay on Your desktop any longer.

If You want to close the app completely once the backup is done:

You need to take the same steps as before - but this time with different code snippet (step 2):

process, close, YourAppProcessName.exe     

In order to learn what Your app’s process name is - You may use Windows Task Manager: just press Ctrl+Shift+Esc and (on the Processes tab) try to find Your app’s item (it often has a recognizable name followed by .exe extension).

Click Image Name column header if it could be better for You to have the list stand still.

Filed in: /37/ | /37/ | /63/ | /7/ | /37/ | /9/

Your (nick)name:

Your e-mail:

Have a website?

Your message:

remember data for further comments?