Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


What is the difference between 'Parent' and 'ParentFolder'

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,27508
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> What is the difference between 'Parent' and 'ParentFolder'
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 What is the difference between 'Parent' and 'ParentFolder' - 10/29/2005 6:52:28 AM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
...In Shell.Application object?

Thanks.

EDIT:
And why

Set shellapp= WScript.CreateObject("shell.application")
WScript.Echo shellapp.NameSpace("f:\windows").Items.Item.Path
 
works?
And

Set shellapp= WScript.CreateObject("shell.application")
WScript.Echo shellapp.NameSpace(0).Items.Item.Path
 
doesn't?

< Message edited by POD64 -- 10/29/2005 7:29:43 AM >
 
 
Post #: 1
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 8:42:43 AM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
What? Please restate your questions with a few verbs, nouns, and other grammar type items added in to help make it a complete coherent question.


Cybex

(in reply to POD64)
 
 
Post #: 2
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 9:38:47 AM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
1) What is the difference between 'Parent' and 'ParentFolder' In Shell.Application object?
2)Why the next two lines work?

Set shellapp= WScript.CreateObject("shell.application")
WScript.Echo shellapp.NameSpace("f:\windows").Items.Item.Path 
 
And these two, don't?

Set shellapp= WScript.CreateObject("shell.application")
WScript.Echo shellapp.NameSpace(0).Items.Item.Path 


(in reply to Cybex)
 
 
Post #: 3
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 10:32:38 AM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
1) What is the difference between 'Parent' and 'ParentFolder' In Shell.Application object?
 
http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/folder/folder.asp?frame=true

Parent is not currently implemented. (And now with VB.NET it probably never will be).

2)Why the next two lines work?

Set shellapp= WScript.CreateObject("shell.application")
WScript.Echo shellapp.NameSpace("f:\windows").Items.Item.Path 

And these two, don't?

Set shellapp= WScript.CreateObject("shell.application")
WScript.Echo shellapp.NameSpace(0).Items.Item.Path  

Change NameSpace(0)  to NameSpace(1) and go from there. For whatever reason, the first element in the array is undefined.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: NameSpace(0).Items

don't get into the habit of handling arrays like this or you may run into trouble in the future. This method is better suited for JScript than VBScript

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to POD64)
 
 
Post #: 4
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 6:24:43 PM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
quote:

Change NameSpace(0)  to NameSpace(1) and go from there. For whatever reason, the first element in the array is undefined. 

But i want to get the path of the special folder "Desktop"...
And how Namespace got to do with array?

(in reply to TNO)
 
 
Post #: 5
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 6:38:03 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline

      

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to POD64)
 
 
Post #: 6
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 6:45:07 PM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
If you want the path of the Desktop why not use this:

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")

A namespace is simply the location where a set of classes are stored. I usually think of this as an array. Which may or may not be a good definition.
Another reason I think of this as an array is because of the vbscript semantics for Arrays: NameSpace(0).

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to POD64)
 
 
Post #: 7
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 6:49:26 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
See the next example for the difference:


      

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to TNO)
 
 
Post #: 8
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 6:58:31 PM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
I'll need more explanation about Namespace.
quote:

Another reason I think of this as an array is because of the vbscript semantics for Arrays: NameSpace(0).
I don't know what are you talking about

Thanks.

(in reply to TNO)
 
 
Post #: 9
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 7:13:16 PM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
About array semantics:

Arrays in vbscript look like this:

Dim A
A = Array(10,20,30)
 
now if I wanted to get the last number "30" I would do this:

B = A(2)   ' B is now 30

So to get a value in the array you would do this A(#). The # being which value you want. So when I see NameSpace(0), The first thing I think is (this is the first value in the NameSpace array).

----------------------------------------
quote:

 
I'll need more explanation about Namespace.


A quick quote from microsoft:

quote:

So what is a namespace? In WMI, you work with things called classes. Classes are virtual representations of real, live things; for example, there is a Win32_Service class that represents all the services on a computer. A namespace is simply the location where a set of classes are stored; in this case, the Win32_Service class is stored in the root\cimv2 namespace.


_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to POD64)
 
 
Post #: 10
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 8:03:52 PM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
TNO, i know how arrays basically look like, i'm an ex-programmer in PASCAL and C++. But this objectes and classes thing is new to me.
So, i would like to know what parameters and constants Namespace and SpecialFolder can get.
BTW, are you familiar with VbsEdit?

(in reply to TNO)
 
 
Post #: 11
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 10:14:26 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
For the SpecialsFolders see the official MSDN link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsprospecialfolders.asp

NameSpace:
As TNO said:
quote:

A namespace is simply the location where a set of classes are stored


_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to POD64)
 
 
Post #: 12
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 10:56:26 PM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
According to the link, i understand that SpecialFolders can has these strings but i found out that it can has also numbers which, i guess, symbolize these strings. Where can i find a documentation for that?
(MSDN suckes, it doesn't describe the topics well )

quote:

A namespace is simply the location where a set of classes are stored

I still don't get it.

< Message edited by POD64 -- 10/29/2005 10:58:19 PM >

(in reply to Snipah)
 
 
Post #: 13
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/29/2005 11:46:08 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Have you downloaded the WSH Documentation?

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to POD64)
 
 
Post #: 14
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/30/2005 1:01:23 AM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
I have a problem with downloading it...

quote:

A namespace is simply the location where a set of classes are stored


Then what is the meaning of namespace(2) or namespace("f:\windows")?

(in reply to Snipah)
 
 
Post #: 15
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/30/2005 3:30:45 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
If you're automatiing scripts for different environments where installations are not standard...and you happen to need to copy something to the Windows folder you can hardcode the path, but if you happen to have a system where Windows is installed on the D-drive with the name "Windoos", you need to call the path as secure as possible...then you need to call the namspace with the (2)....



_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to POD64)
 
 
Post #: 16
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/30/2005 5:42:28 AM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
O.K, i realize that, but where the classes get into the picture?

(in reply to Snipah)
 
 
Post #: 17
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/30/2005 8:46:07 AM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
quote:

But this objectes and classes thing is new to me.



From the world of C++ I'm sure you've used objects:

"Objects work so well because they act just like real life objects- objects have properties and methods. So if we were talking about a lamp, a property of it may be its height or width, say 12cm. A method of it may be to shine (an action). And when it's shining, its brightness property would be of a greater value than when it wasn't."

Classes are like generic objects. Think of it like this:

Object: Raven
Object: Canary
Object: Ostrich

Class: Birds

So a class can create objects with a group of properties and methods.
A namespace is simply the location where a set of classes are stored.

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to POD64)
 
 
Post #: 18
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/30/2005 9:04:39 AM   
  POD64

 

Posts: 23
Score: 0
Joined: 10/25/2005
Status: offline
O.K, but when i'm running this

Set shellapp= WScript.CreateObject("shell.application")
WScript.Echo shellapp.NameSpace(2)

I'm getting an object of a folder, in this case it's the Programs folder. It looks to me like BrowseForFolder getting one of the constants.

(in reply to TNO)
 
 
Post #: 19
 
 RE: What is the difference between 'Parent' and 'Parent... - 10/30/2005 8:17:16 PM   
  TNO


Posts: 1302
Score: 12
Joined: 12/18/2004
From: thenewobjective.com
Status: offline
I couldn't have said it better:

quote:


In Windows 95 and later, the file system is just one possible place to store and search for information. As a result, the pre-Win95 hierarchy of files and directories no longer adequately describes the possible objects that you can now access in Windows. New types of folders such as the Recycle Bin, My Documents, and Printers forced the adoption of a new programming interface. In this new programming interface, Folder objects represent Windows shell folders that contain files or references to other types of objects. (The Folder object in the Windows Shell object model isn't related to the Folder object in the File System Object—FSO—object model. The objects simply share the same name.) Because files no longer solely define a folder's content, more general objects called FolderItem objects represent the items in a folder. A FolderItem can be a file or a chunk of data that represents, for example, a printer or deleted file. A collection called FolderItems represents all the FolderItem objects in a folder.

Because a folder is essentially a container that holds data, you can use a common set of methods and properties (i.e., the Folder object's methods and properties) to access many different types of objects. As a container of data, a folder is able to describe itself in terms of name, title, path, and content. The content can vary widely depending on a folder's particular role. For this reason, each folder implements a special functionality: the ability to enumerate child items (i.e., FolderItem objects). Each child item, in turn, has fixed properties and methods that you use to manipulate it. Here's a look at how you use the methods and properties of the Folder and FolderItem objects.
...
You typically don't create instances of the Folder object directly. Instead, use the NameSpace method with a pathname or virtual folder ID to create instances.
...
After you create an instance of the Folder object, you can use its properties and methods.


Quoted from: http://www.windowsitpro.com/Article/ArticleID/15847/15847.html?Ad=1

_____________________________

To iterate is human, to recurse divine. -- L. Peter Deutsch

(in reply to POD64)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> What is the difference between 'Parent' and 'ParentFolder' Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts