Windows Scripting
  Home arrow Windows Scripting arrow Page 3 - WSH in Other Languages
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 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? 
WINDOWS SCRIPTING

WSH in Other Languages
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2008-08-11

    Table of Contents:
  • WSH in Other Languages
  • VBScript
  • Jscript
  • Python
  • More Languages

  • 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


    WSH in Other Languages - Jscript


    (Page 3 of 5 )

    Jscript was also released in 1996 by Microsoft to meet the ECMAScript scripting programming language specifications.  It most closely resembles Netscape’s own ECMAScript solution known as JavaScript.  While the terms Jscript and JavaScript are often erroneously used interchangeably, it is important to remember that the two represent completely different and independent entities.  Despite their close resemblance, Microsoft retained enough differences to keep the two languages incompatible.

    Because of Jscript’s wide use as a web development language, its support was also included in WSH natively.  This makes it the perfect alternative to VBScript for many administrators.

    var fso = new ActiveXObject("Scripting.FileSystemObject");

    An object can be accessed by creating a new instance of the object with the ActiveXObject method.  Just as in VBScript, an object is typically identified by its ProgID.

    var folder = fso.GetFolder("C: emp");

    Like VBScript, Jscript uses standard object dot syntax to access an object’s properties and methods.

    Working with Collections

    Unlike VBScript, Jscript cannot access collection objects directly.  You must first create an Enumerator object.

    var e = new Enumerator(folder.files);

    An enumerator object provides a mechanism for accessing and manipulating the objects found within a collection.

    for (e.moveFirst(); ! e.atEnd(); e.moveNext()) {

       var file = e.item();

       WScript.Echo(file.name);

    }

    Iterating through the enumerator’s items is then done using a For structure.

    Additional Notes About Jscript

    All statements in Jscript require a semi-colon line ending and parenthesis should be used to denote all methods even when you are not supplying parameters.

    Unlike VBScript, Jscript does maintain some case sensitivity.  Variables and object names are case sensitive, while an object’s property and method names are not.

    It is also important to remember that the forward slash is a reserved character and must be escaped whenever it appears in a string.

    More Windows Scripting Articles
    More By Nilpo


       · The Windows Script Host is not limited to VBScript and JScript. In fact, you can...
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek