Greg Shultz shows you how to create a Reminder Script using Windows Scripting Host in Windows 7.
I recently found myself in a situation where I needed to be reminded to perform an additional task once I finished working in an application. I had originally thought about using Windows 7's Sticky Notes app as a solution. However, while Sticky Notes are great for little notes, you still have to remember to look at them. What I really wanted was a reminder in a popup dialog box -- something like Outlook's Appointment Reminder.
As I toyed with the idea some more, I remembered Windows Scripting Host's Popup method. I then developed a simple tool called the Reminder Script, which allowed me to link reminders to a few of my applications. After using my Reminder Script for a while, I figured that other folks out there might find it as useful as I have.
In this edition of the Windows Desktop Report, I'll show you how to use Windows Scripting in Windows 7 to create a Reminder Script that you can customize for your particular situation. As I do, I'll explain each step in detail.
Creating a template for your Reminder Script
To begin, you'll create a template for your Reminder Script. This template will provide you with the basic framework you'll need to create a fully functioning Reminder Script that's customized to your needs. The Reminder Script can be configured to display a reminder before the application launches or after you close the application. The version you choose will depend on when the reminder is appropriate for your situation.Creating the template for the Reminder Script is easy. To begin, launch Notepad and type the commands shown in Figure A. Be sure that you type all the commands exactly as shown. If you don't, the script won't work correctly. When you've finished, save the file as Reminder.vbs.
Creating a shell for your Reminder Script will help you to understand the commands used to perform the technique.
Before I show you how to customize the Reminder Script template, let's take a general look at how the script works. Doing so will give you a better understanding of how the commands in the template function and will make it easier for you to customize the script later.
The first line in the script creates a variable called WshShell and provides it with access to some of the Windows operating system objects that the Windows Scripting Host makes available to the scripting languages. In this script, we'll take advantage of the functions that launch applications and display message boxes.
The second line in the script uses the WshShell.Run command to launch the application. The WshShell.Run command contains three parameters, each of which is separated by a comma. The first parameter is the path to an executable filename and is enclosed in double quotes. The second parameter is the window size parameter, in this case 1, which configures the application to launch in a normal window. The third parameter, True, prevents the script from processing the next command until the application is closed.
The third line in the script uses the WshShell.Popup command to create the message box. The message that it will display will be enclosed in the parentheses and double quotes. The fourth line uses the Wscript.Quit command to exit the script.If you want to display the reminder before the application actually launches, you just switch the position of the WshShell.Run command and the WshShell.Popup command, as shown in the template in Figure B. You'll also notice that I changed the last parameter in the WshShell.Run command from True to False. The reason for the change is that you want to ensure that the Wscript.Quit command is immediately processed after the application closes.
This template will display the reminder before the application launches.
Launching the application
As I mentioned, you'll use the WshShell.Run command to launch your application. Unfortunately, using the WshShell.Run command can be a little tricky if you are unaware of its shortcomings. The WshShell.Run command won't allow you to use filenames or folder names that contain spaces without a bit of trickery. However, a work-around isn't necessary in all cases. Let's take a closer look.
If the application's executable file is located in a folder that is in the operating system's path, then you can just use the executable filename in the WshShell.Run command. For example, Wordpad's executable file, wordpad.exe, is located in C:\Program Files\Windows NT\Accessories. However, this path is recognized by the operating system, so you can just use the executable filename in the WshShell.Run command.
WshShell.Run "wordpad.exe", 1,True
On the other hand, I have a third-party application called Maple Professional, and its executable file, maple.exe, is located in C:\Program Files (x86)\Maple Professional. Now, this path is not inherently recognized by the operating system, and the path contains spaces, so you have to use the full path and trick the WshShell.Run command into accepting the spaces by padding with extra double quotes. Note that I have used three double quotes on each end of the path.
WshShell.Run """C:\Program Files (x86)\Maple Professional\maple.exe""", 1,True
To determine if the application is in a path recognized by the operating system, open the Run command (press [Windows]+R), type the executable filename, and click OK. If the application launches, then you can use just the executable filename in the WshShell.Run command. If it doesn't launch, then you have to use the full path and pad it with extra double quotes.
Customizing the Reminder ScriptCustomizing the Reminder Script is easy. Let's suppose you want to display a message after you close Word that reminds you to email your documents to a colleague. The executable file that loads Word is winword.exe, and it's in a path recognized by the operating system. As such, I can just use the executable filename in the WshShell.Run command. When you do, make sure that you include the quotation marks surrounding the command line, as shown in Figure C. If you don't, your script won't work properly.
Since Word's executable file is in a path recognized by the operating system, I can just use the executable filename in the WshShell.Run command.
At this point, save the file with an appropriate name. For example, I saved my example file as Word Reminder.vbsNow, you'll type your reminder message in between the quotation marks in the WshShell.Popup command. Continuing with our example, you'll type a message that reminds you to email your documents, as shown in Figure D.
Type your reminder message in between the quotation marks in the WshShell.Popup command.
To complete this part of the operation, save your script file and close Notepad. You're now ready to configure the Reminder Script shortcut.
Configuring the shortcut
After you create your Reminder Script file, you'll create a shortcut to the VBS file. You'll then change the icon of the shortcut to the icon used by the application that your Reminder script points to.
To begin, locate the Word Reminder.vbs file in Windows Explorer. Right-click on the file and drag it slightly to the right and drop it. When you see the shortcut menu, select the Create Shortcuts Here command. Now, right-click the new shortcut and select the Properties command.When you see the Word Reminder.vbs Properties dialog box, click the Change Icon button. Now, click the Browse button, locate and open the winword.exe file, select its icon, and click OK. At this point, your Word Reminder.vbs Properties dialog box will look like the one shown in Figure E.
You'll assign the application's icon to your shortcut.
Using the Reminder scriptSince the Reminder script will both launch your application and display your reminder message, you'll need to replace your current Word shortcut on the Start menu or desktop with the new shortcut you just created. Now, whenever you finish working in Word and exit the application, you'll see a message box like the one shown in Figure F, which in this case reminds me to email my files to Joe.
When you close your application, you'll see the reminder.
What you take?
Have you wished that you could attach a reminder to an application that would prompt you to perform an additional task associated with that application? Can you see another use for the Reminder Script? As always, if you have comments or information to share about this topic, please take a moment to drop by the TechRepublic Community Forums and let us hear from you.