Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


August 08, 2005

Handy HTAs: Set and Display User Quotas

This sample utility shows you how to create input forms
RSS
Subscribe to Windows IT Pro | See More VBScript Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

When you need to create input forms, HTML Applications (HTAs) can be a near-perfect solution, as I explain in "Hooked on HTAs," August 2005, InstantDoc ID 46795. With just a little practice, you can create HTAs like the one I'm going to show you. This fully functional sample form, which I've named User Quota Utility, lets you set and display disk quotas on local and remote Windows Server 2003 and Windows XP computers. Even if you don't use quotas, this form is a useful example of how to develop administrative utilities by using an HTA and VBScript. If you use Windows 2003 or XP but haven't enabled quotas, you can do so (by using the Properties dialog box) on a local disk so that you can try out this sample HTA. In that situation, don't select the Deny disk space to users exceeding quota limit check box. If you select that check box, you might accidentally deny a user the ability to write to disk if the quota is exceeded. (For information about using quotas, see the Microsoft article "Managing Disk Quotas in Windows Server 2003 and Windows XP" at http://www.microsoft.com/technet/scriptcenter/topics/win2003/quotas.mspx.)

The HTA at a Glance
Figure 1 shows User Quota Utility: an input screen that consists of four input fields, one drop-down box, two buttons, and two text boxes. Let's take a look at these components and at how the utility works.

The input boxes. The first input box lets the user enter a list of user IDs for the user accounts that require quota changes. In the second input box, the user enters the name of the server or computer on which the quotas reside. (If this field is left blank, the utility defaults to the local machine.) If the specified user IDs are domain accounts or accounts on another computer, the user needs to enter the domain or computer name in the third input box. (If this field is left blank, the utility again defaults to the local system.)

In the fourth input box, the user enters the quota size, in bytes. As you can see in Figure 1, I've hard-coded in a default of 5368709120, or 5GB, but you can easily modify that number. In the event that you prefer to give users a choice of entering this data in bytes, megabytes, or gigabytes, I created a second HTA (UserQuotaUtility2.hta) that provides all three options, as Figure 2 shows.

The drop-down box. The drop-down box, located directly after the second text box, lets the user select the drive letter of the computer on which the quotas reside. The drop-down box in this sample HTA uses a pretty lengthy list of drive letters. I've set the default value to the C: drive.

The buttons. When the user clicks the first button, labeled Run Modify User Quotas, User Quota Utility attempts to set the specified quota on the chosen systems. This action is associated with the RunMod subroutine in the HTA's VBScript section, which Listing 1 shows.

The second button, labeled Run Quota Query, lists quota information for a specific server and drive. This action is associated with the RunQuery subroutine in the HTA's VBScript section. The application doesn't filter user IDs when running this subroutine; instead, it lists all user quota settings for the specified computer and drive. Even when the user has listed user IDs in the first input box, clicking the Run Quota Query button will return information about all accounts on the specified system, not just the listed accounts.

The text boxes. The first text box, labeled Status Box, displays the status (i.e., successful or unsuccessful) of the most recent action. The second text box, labeled Application Information, is a summary of the application, including some instruction. These two boxes are the same types of text boxes that the utility uses for input but are declared ReadOnly, which prevents users from entering text. (You can programmatically change the contents of these text areas by assigning a different value to the fieldnames.value code in the HTA script.)

Inside the HTA
The HTA starts with the basic HTA application settings (see "Hooked on HTAs" for details about the available settings). The entire HTA is too long to print, but you can download the file (UserQuotaUtility.hta) from the Windows Scripting Solutions Web site. (Go to http://www.windowsitpro.com/windowsscripting, enter 47101 in the InstantDoc ID text box, then click the 47101.zip hotlink; the .zip file also includes UserQuotaUtility2.hta.) To view the script, open the HTA file in Notepad.

After the application settings, the HTA includes the VBScript section, which Listing 1 shows. This section contains three subroutines: Window_Onload, RunMod, and RunQuery.

Window_Onload. The Window_Onload subroutine executes automatically when the application is launched. First, the subroutine uses self.Focus() to launch the application window in front of any other open windows. The subroutine then sizes the application window and sets the default quota size (qlimit.value).

   Previous  [1]  2  Next 


Reader Comments

You must log on before posting a comment.

If you don't have a username & password, please register now.




Top Viewed ArticlesView all articles
The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...

Friday at PASS Europe 2006

Kevin talks about the closing day of the event and shares a funny Microsoft film. ...

Escape From Yesterworld

Kevin points you to the funniest SQL Server website ever! ...


Related Articles Go Go Gadgets

Related Events Check out our list of Free Email Newsletters!

Scripting eBooks Keeping Your Business Safe from Attack: Encryption and Certificate Services

Best Practices for Managing Linux and UNIX Servers

Building an Effective Reporting System

Related Scripting Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.

Job Openings in IT


ADS BY GOOGLE SPONSORED LINKS FEATURED LINKS

Maximize your SharePoint Investment – 8 Cities
Discover best practices and tips for both architecting and administering SharePoint. Early Bird Price of $99 through Sept 15th.

Find a new job now on the all new IT Job Hound!
Search jobs, post your resume, and set up job e-mail alerts!

Master SharePoint with 3 eLearning Seminars
Learn how to build a better SharePoint infrastructure and enable powerful collaboration with MVPs Dan Holme and Michael Noel. Register today!

Top Tools for Virtualization Disaster Recovery & Replication
View this web seminar on August 14th to learn about two tools that will result in faster backup and restore with P2V disaster recovery.

SharePointConnections Conference Fall 2008
Don’t miss the premier event for Microsoft IT Professionals in Las Vegas, November 10-13. Register and book your room by August 25 and receive a FREE room night (based on a three night minimum stay).

VMworld 2008 - Sign Up Today!
Join your peers on September 15-18 at The Venetian Hotel in Las Vegas as VMware hosts VMworld 2008, the leading Virtualization event.



Entrust Unified Communications Certs
Secure Exchange 2007 and save 20%. Now through Sept. 2008.

Increase Application Performance
Free White Paper by Editor's Best winner, Texas Memory Systems.

Need to convert between XML, DBs, EDI, and Excel? Try MapForce free!
Drag & drop to transform between popular data formats – get results instantly or generate code.

Microsoft® Tech•Ed EMEA 2008 IT Professionals
Advance your thinking with new ideas and practical real-world solutions at Microsoft’s FIVE day technical infrastructure conference 3-7 Nov., 2008. Register before 26 September 2008 to save €300.

Order Your SQL Fundamentals CD Today!
Learn how to use SQL Server, understand Office integration techniques and dive into the essentials of SQL Express and Visual Basic with this free SQL Fundamentals CD.

Are You Really Compliant with Software Regulations?
View this web seminar that will help you with compliance best practices and check out a management solution to assure that you won’t be in jeopardy of an audit.

Virtualization Congress Oct. 14-16 in London
Don't miss Virtualization Congress, the premiere EMEA conference dedicated to hardware, OS and application virtualization. Oct. 14-16.
Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technical Resources Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2008 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing