Home page rotator |
Written by Ian Elliot | |||||
Tuesday, 09 February 2010 | |||||
Page 2 of 4
SetupNow we have the broad outline it is time to get to work. As everything is going to be in VBScript, which is easy to convert to JScript if you want to, we don't need any language environments installed. It is, however, worth making sure that you have the latest version of the Windows Scripting Host and script engines installed – check on the Microsoft website. You can also create and modify all of the scripts using nothing but Notepad or you can use an editor such as Visual Web Developer Express edition (which is free to download from the Microsoft website). As the whole system is composed of a number of scripts we really need an installation script that will set everything up and an uninstall script to return everything to how it was. As the setup script does a great deal of the hard work this seems like a good place to start. Create a folder where you are going to store all the scripts relating to this project – it doesn't matter what it's called or where it is. A good setup program should be able to install everything irrespective of the location of the project resources. Create a file called Setup.VBS in the directory. It's a good idea to give the user a chance to change their mind before installing: button=Msgbox("You are about to setup Now we have all of the work being done by the Setup subroutine. The subroutine divides into three parts –
To do all this we need two auxiliary objects – the WshShell object which provides ways of interacting with the system and the FSO object which provides ways of interacting with the filing system: Sub Setup We need to find out where the user's program folder and System32 folder are. It would be simpler just to assume their standard names but it isn't very much extra work to ask the system for them just in case they are non-standard. The key to this is to read the environment variables: 'Get folder names This gets the program folder's name, usually Program Files, and adds the name of the directory we are going to use to store all of the applications files, i.e. \HomePageRotator. Originally it was planned that this would store the entire installed project but it turned out that it was much easier to put the scheduled script into the System32 folder to avoid having to specify a path. The full name of the System32 folder can be found using: Set WshSysEnv = _ Finally we need the current directory where all of the project files, including the setup script, are stored: currentdir= WshShell.currentdirectory If the project folder doesn't exist we need to create it: if not(fso.folderexists(ProgFolder)) then Now we can copy the two key project files starting with the script that is triggered when the user selects the custom item in Explorer's context menu: fso.copyfile currentdir & _ This script has to be stored in an HTML file and exactly what it does will be explained later but essentially it creates the list of home pages that we want to rotate. The second script is the one that uses the list to move on to the next home page each time it is triggered: fso.copyfile currentdir & _ This script, rotate.vbs, is a standard VBScript and again we will return to how it works later. <ASIN:0596004885> <ASIN:0470168080> <ASIN:0735622442> |
|||||
Last Updated ( Monday, 08 February 2010 ) |