JavaScript
  Home arrow JavaScript arrow Advanced JavaScript with Internet Explorer...
Web Buyers Guide
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Download TestComplete 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Web Buyers Guide
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Advanced JavaScript with Internet Explorer: Working with Drives and More
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2006-03-28

    Table of Contents:
  • Advanced JavaScript with Internet Explorer: Working with Drives and More
  • A better approach to retrieving a list of drives using JavaScript
  • How to know the number of partitions of each physical drive using JavaScript
  • How to learn more information about each partition using JavaScript
  • How to list all folder/file information (including sub-folders) using JavaScript
  • How to list all folder information for a particular sub-folder using JavaScript

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Advanced JavaScript with Internet Explorer: Working with Drives and More
    (Page 1 of 6 )

    This series mainly concentrates on retrieving system information using JavaScript and displaying the same on a web page. All of the examples in this series can be directly tested by copying and pasting the entire code (of each section) in any text file with the extension .HTM and opening it using Microsoft Internet Explorer (preferably 5.5+).

    In general, JavaScript is used mainly for web designing, DHTML and other interactive forms.  Not everyone knows that we can use JavaScript to retrieve system information (supported only with Internet Explorer). 

    In fact, JavaScript can connect to any computer (with proper authentication) and retrieve (and modify as well) system information, including the client where the browser is opened.  This gives us the path for implementing a WBEM (Web Based Enterprise Management) strategy.  But, it is a bit difficult to understand everything about WBEM all at once.

    In this series, I mainly concentrate on how-to topics for retrieving system information using JavaScript. 

    How to retrieve a list of drives using JavaScript

    Now, let us try to develop a simple script (JavaScript) which shows the technique for retrieving a list of drives and displaying it on a web page. The entire code for the sample is as follows:

    <!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
          <head>
                <title></title>
                <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
    7.1">
                <meta  name="vs_targetSchema"
     content="http://schemas.microsoft.com/intellisense/ie5">
          <script  id=clientEventHandlersJS  language=javascript>
    <!--

    function Button1_onclick() {
          var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
          var service = locator.ConnectServer(".");
          var properties = service.ExecQuery("SELECT * FROM
    Win32_LogicalDisk");
          var e = new Enumerator (properties);
          for (;!e.atEnd();e.moveNext ())
          {
                var p = e.item ();
                document.write("Drive: " + p.Name + " -> Size: " + p.Size +
    "<br>");
          }
    }

    //-->
    </script>
    </head>
          <body>
                <INPUT  id="Button1"  type="button"  value="Button"
     name="Button1"  language=javascript  onclick="return Button1_onclick()">
          </body>
    </html>

    Actually, within the above code, the “meta” tag is not necessary.  As I developed the above code using Visual Studio.NET 2003 Enterprise Architect, it was automatically added to provide its full-featured mechanisms. 

    The above would automatically list all the drives along with their sizes.  To retrieve drive information, I used a built-in class, “Win32_LogicalDisk.”  The class internally has a lot of properties, methods and events.  But, in the above example we concentrated only on the properties “Name” and “Size” (related to “Win32_LogicalDisk” class).

    The “for” loop I used in the above code iterates for every logical drive present in the system and finally retrieves only the properties of that drive.

    Another interesting issue to discuss is the following:

          var service = locator.ConnectServer(".");

    According to the above statement, it connects to the system where the web page (or browser) is opened.  If you need to connect to other systems, you must specify the name of the system by replacing the dot (“.”) in the above statement.  You can also provide IP if necessary.  It would connect to the other computer if and only if a trusted connection exists between both computers (otherwise we need to provide authentication information as well).

    More JavaScript Articles
    More By Jagadish Chaterjee


       · Hello guys, Can you believe that JavaScript can work with...
       · This is code for MSIE Only. Should'nt be relied upon in the real world with the...
       · That's because the non-IE browsers suck. Despite all the hype IE is far superior...
     

    JAVASCRIPT ARTICLES

    - A Closer Look at Smart Markers with Yahoo! M...
    - Using Polylines and Smart Markers with Yahoo...
    - Bulleted Menu of Links
    - Creating Click Loggers and Basic Markers wit...
    - Adding Pan Controls to Yahoo! Maps
    - Adding Zoom Controls to Yahoo! Maps
    - Working with Yahoo! Maps
    - Building Image Zooming Controls with the DOM...
    - Working with Multiple Graphics for a Zoom Ap...
    - Improving an Image Zooming Application with ...
    - Zooming in on Images with JavaScript
    - JavaScript Date Objects: Universal Coordinat...
    - Javascript Objects: More Date Methods
    - JavaScript Objects: Dates
    - JavaScript Objects: Finishing Strings


     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway