Code Examples
  Home arrow Code Examples arrow Page 4 - Coding a Custom Object with WSC
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? 
CODE EXAMPLES

Coding a Custom Object with WSC
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2009-03-31

    Table of Contents:
  • Coding a Custom Object with WSC
  • Adding code for the object methods
  • Adding objects and resources
  • Registering and using your component
  • Protecting your intellectual property

  • 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


    Coding a Custom Object with WSC - Registering and using your component


    (Page 4 of 5 )

    With all of the pieces in place, you’re ready to put your new component to the test.  Make sure that you save the latest changes and move it to a directory where you can leave it.  Once a component is registered, it cannot be moved, because the system is going to save its location.

    You should be able to register and unregister your component very easily using the context menu entry in My Computer.  Navigate to the directory where you put it, right-click on the WSC file, and choose Register.  If you don’t have an option to register it, you can do it from the command line as follows.

    regsvr32 “C:pathtoZipFolder.wsc”

    Once your component has been registered, it is immediately available to the system.  You can write a script now that implements your object by instantiating it by its Prog ID.

    Set objZipFolder = CreateObject("ZipFolder.WSC")

    One of the beauties of using WSCs over compiled code is that now, even though it’s already registered, you can still open the file and make changes without having to unregister and re-register the component.  Changes will take effect immediately!

    While you really should always register your components, let’s assume for some reason that you don’t want to.  Maybe you're in a really restricted environment or only intend to use your component a couple of times.  In any case, there is one little-known method for instantiating a Windows Script Component without having to register it on the host system.

    Set objZipFile = GetObject("script:C:componentsZipFolder.wsc")

    You can use the GetObject method to instantiate your script component directly.  The magic is the use of the script: protocol.  You will need to provide the full path to the WSC file.  But that’s not all…

    Set objZipFile = GetObject("script:ServercomponentsZipFolder.wsc")

    …it can be any valid file path—including network paths…

    Set objZipFile = GetObject("script:http://www.example.com/pub/ZipFolder.wsc")

    …and even web locations!

    More Code Examples Articles
    More By Nilpo


     

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





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