|
![]() |
Have you ever wanted to automate a program that normally does not support automation? For example, the Microsoft Backup program that ships with Windows 98 does not support automation. This means that in order to run the backup program I have to go and manually open and select the proper backup options then run it. What a pain in the ass! Why can't I just add it to the task scheduler and be done with it. Well, I found a way to do just that and it should work with just about any program you want it to.
Microsoft included a little bit of technology that allows users to create and run their own scripts that take nothing more than the notepad. You just type your script, save it with the proper extension and then double click to run it. (Or to automate it just add it to the task scheduler and set a time.) The script runs and acts as if a user is typing on the keyboard to send the appropriate commands to the program.
Here is an example script I wrote to automate the Microsoft Backup program. The only thing you have to do is set up the Backup Program manually first and save a backup profile. I did this and named it "My Documents". (As you can guess, it is set to backup the directory My Documents.) Then to write a script that will open and run the backup profile named "My Documents" all you have to do is:
1. Open Notepad
2. Type this in:
Dim ss
Dim starttime,waittime,currenttime
waittime = 5
Set ss = CreateObject("WScript.Shell")
ss.run "C:\PROGRA~1\ACCESS~1\BACKUP\MSBACKUP.EXE",1
starttime = Timer()
currenttime = starttime
Do Until currenttime-starttime > waittime
'Do nothing
currenttime = Timer()
Loop
ss.SendKeys "C%JOMy Documents{Enter}%S"
Set ss = nothing
3. Save this file with the extension set to .vbs. (ex. Backup.vbs)
4. Close Notepad
5. Double Click the file Backup.vbs to run it.
You will notice the command "ss.run" this command is the one that runs the program you want to automate. You should subsitute the full path of the program you are attempting to run here.
I also added a 5 second timer to the script so as to allow the programs splash screen to go away, otherwise the sendkeys command will send keys to the program and the programs splash screen will accept them but do nothing.
Sendkeys is the real trick here. It acts as if someone were typing at the keyboard. So you see, this implementation could extend to almost any program on your system. You could create small scripts to do tedious tasks for you.
Let me know what you think, if this was helpful or stupid?