Scripting an administrative Web interface for the printer mapping utility
In "A Printer Mapping Utility" April 2002, InstantDoc ID 24368, I described how to display printer locations within your organization by placing printer icons on floor-plan maps. Map positions result from x and y coordinates (pixel offsets) for the Location attribute of each networked printer. Manually calculating pixel offsets for more than a few printers is time-consuming; maintaining pixel offsets in a large network in which printers might move weekly is challenging. To address these obstacles, you can use a script that runs in a Web browser to administer printer locations. In the second article in my series, "The Code Behind the Printer Mapping Utility," May 2002, InstantDoc ID 24598, I discussed the details of the PrintersMap.asp script. In this article, the third and last in the series, I discuss how to configure an administrative Web interface for the printer mapping utility, install and configure the utility, and prepare and run the script. Finally, I detail how the script works.
Configuring Printers
First, click a floor map to specify pixel offsets, as Figure 1 shows. The x and y coordinates, separated by "x" and in parentheses (e.g., 120 x 300), will appear in the Map position text box. Next, select a printer that you want to reposition from the Select a printer share list. The printer's location information, if any, will appear in the Printer location text box. With both the Printer location and Map position text boxes populated, you can click either Append or Replace to insert a value in the New location text box: Click Append to concatenate the value in the Map position text box to the value in the Printer location text box, and click Replace to insert the value in the Map position text box into the New location text box. If necessary, you can edit the value in the New location text box. If you click Append and the data in the Printer location text box contains the previous coordinate value along with the new coordinate value, you'll want to edit the value in the New location text box.
When the value in the New location text box is correct, click Update to apply the location change. When a Microsoft Internet Explorer (IE) message box appears, click Retry to see the updated printer map.
To save space, Figure 1 shows only a small portion of the floor map. However, make sure that you view the entire floor map when you select printer coordinates. If you don't view the entire page, the pixel offset values will be incorrect.
This script relies on both client-side JScript and server-side VBScript code. HTML and Active Server Pages (ASP) render the pages, and Dynamic HTML (DHTML) provides advanced form features. Windows Management Instrumentation (WMI) and Active Directory Service Interfaces (ADSI) provide read and write access to printer information.
Installing and Configuring the Interface
After you configure the printer mapping environment, which I outlined in detail in "A Printer Mapping Utility" and "The Code Behind the Printer Mapping Utility," copy the following files from the Windows Scripting Solutions Web site (http://www.winscriptingsolutions.com) to the Main directory, which is a subdirectory of the PrintersMap virtual directory:
- defaultadmin.htm*the initial print-server selection page
- printersmapadmin.asp*the printer mapping administration script
- stylesheet.css (updated for the administrative interface)*the style sheet that replaces the original style sheet in the Img directory
- bigmask.gif*an image that the coordinate mapping feature uses to obtain x and y coordinates