Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 31st, 2008, 07:29 PM
Hangman Hangman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 29 Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 h 56 m 6 sec
Reputation Power: 0
General Scripting - What's the difference ...

Can someone tell me the difference between the WSH and VBScript ?? And perhaps there isn't a difference, or perhaps there is, ... I dunno.
The reason I ask is this, I have some code which reads:
Code:
Dim fs
Set fs = CreateObject("scripting.filesystemobject")

I then have from my book the following:
Code:
Dim fs
Set fs = WScript.CreateObject("WScript.FileSystemObject")

What is the difference between these two pieces of code ??
Is the first VBScript ??
Am I forcing a specific when using WScript.### ??
Why does the first work the same as the second even though they are different ??
Too many questions for one post. But the book doesn't cover these "inquiring minds want to know" desires, it simply tells you what to do and where to go.
Thank you so much for your help, it is really appreciated.

Reply With Quote
  #2  
Old August 1st, 2008, 02:09 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
You've asked very good questions. Let me see if I can explain this.

First, let's look at the acronyms. WSH stands for Windows Script Host and VBScript stands for Visual Basic Scripting Edition.

The Windows Script Host is a scripting environment that can execute code written in a variety of languages. One of these such languages is VBScript.

VBScript is a COM-enabled language meaning that it allows you to access global COM objects that are native to the system. It provides the CreateObject and GetObject methods for accessing these objects. This is illustrated in your first example.

The Windows Scripting Host also provides two methods by the same name, for the same purpose. These can be accessed through the WSH's own COM object, WScript as in the second example. Since the WScript object is available at script execution, it is available to languages that do not provide ways of connecting to COM objects and exposes these two methods to add that functionality. That's why the methods appear as children of the WScript object as denoted by the dot syntax. (WScript.CreateObject as opposed to just CreateObject). Without specifying an object as the parent, WSH would assume the global method provided by VBScript as in the last example.

In most cases, VBScript's methods and WScript's methods can be used interchangeably. They do the same thing by connecting to and returning a reference for a COM object. WScript's version does add functionality that allows you to do event driven programming, but they are the same for all intents and purposes since that is far beyond the scope of this post.

COM objects are most commonly instantiated by their ProgID, a text string that identifies the object. "Scripting.FileSystemObject" is a generic ProgID that refers to the Windows Scripting Host's FileSystemObject, a COM object that exposes properties and methods for working with files and folders. The "WScript.FilesystemObject" ProgID references the same object, although the first ProgID is most commonly used.
__________________
Click the image if at any point you don't like my decision.

Scripting problems? Windows questions? Ask the Windows Guru!


Reply With Quote
  #3  
Old August 1st, 2008, 05:40 PM
Hangman Hangman is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 29 Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level)Hangman User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 6 h 56 m 6 sec
Reputation Power: 0
Nilpo,
So is there a better and worse practice to the use of this code, or is it more a personal preference; less typing, etc. ??
And the COM objects accessed from the WSH, are they only the embedded ones, another words, the ones native to windows ?? I would assume so as third party software would have their own ProgID if they have one at all. I have another post which trails a little deeper into this I think.
Thank you.

Reply With Quote
  #4  
Old August 1st, 2008, 06:12 PM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Beginner (1000 - 1499 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 1,254 Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)Nilpo User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1Folding Points: 206875 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Days 10 h 25 m 34 sec
Reputation Power: 667
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo Send a message via XFire to Nilpo
Facebook MySpace Orkut
Quote:
Originally Posted by Hangman
Nilpo,
So is there a better and worse practice to the use of this code, or is it more a personal preference; less typing, etc. ??
And the COM objects accessed from the WSH, are they only the embedded ones, another words, the ones native to windows ?? I would assume so as third party software would have their own ProgID if they have one at all. I have another post which trails a little deeper into this I think.
Thank you.
Again, unless you're doing event-driven work, you can use either VBScript's or WScript's set of methods. I typically used VBS's since it saves some keystrokes.

You should also use the "Scripting.FileSystemObject" ProgID. This is the generic ProgID that represents the newest FSO object on the system.

As far as COM objects go, you can use any of them that are installed on the system--native or third-party--so long as they provide a scripting interface.

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > General Scripting - What's the difference ...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT