Quick survey on what’s coming:
- How to schedule any app’s launch under Windows?
- How to automatically close the app?
- If You want just to close the app’s window once the backup is done...
- 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):
- 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.
- On the right side of the Task Scheduler’s window You should see Actions area, with several items to choose. Pick Create Basic Task.
- 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.
- 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.
- 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.
- As an action choose Run a program, click Next.
- 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:
Open Your text editor (e.g., Notepad) and create a new text file, save it as YourName.ahk (e.g., Close-YourAppName.ahk).
Copy&paste the following code into Your file:
PostMessage, 0x112, 0xF060,,, **Xxx** ; 0x112 = WM_SYSCOMMAND, 0xF060 = SC_CLOSE return
The code above is similar in effect to pressing Alt+F4 or clicking the window’s close button on its title bar.
( source » )
- 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).
- Save the changes (CTRL+S) and close Your text editor.
- 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.
- 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 ᴘ.ᴍ..
- 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
return
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).
Filed in: life hack /37/ | work hack /37/ | software /63/ | smart backup /7/ | Windows /37/ | AutoHotkey /9/Click Image Name column header if it could be better for You to have the list stand still.