From: "Dave "Crash" Dummy" on
Stefan Kanthak wrote:
> "James Whitlow" <jwhitlow.60372693(a)bloglines.com> wrote:
>
>> "Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
>> news:lMV2o.35016$lS1.31785(a)newsfe12.iad...
>>> How can I address special folders, like "My Documents" and "My Pictures"
>>> in script?
>
> Option Explicit
>
> Dim intFolder
>
> With WScript.CreateObject("Shell.Application")
> For intFolder = 0 To 63
> With .NameSpace(intFolder)
> On Error Resume Next
> WScript.Echo "[" & intFolder & "]:" & vbTab & .Title & " = " & .Self.Name & vbNewLine & vbTab & .Self.Path & vbNewLine
> On Error Goto 0
> End With
> Next
> End With
>
>>> I can address the actual location as indicated in the folder
>>> shortcut, but that doesn't show up in Explorer. For example, to address
>>> the image shown in Explorer as "C:\Users\David\My
>>> Pictures\snapshot.png," I have to look in the "My Pictures" folder
>>> properties to find the location (C:\Users\David\Pictures) and use that in
>>> my
>>> script. Is there some way to address or locate special folders directly?
>> For many folders, you can use the 'SpecialFolders' method of
>> 'WScript.Shell'.
>>
>> Set oWSH = CreateObject("WScript.Shell")
>> sMyDocuments = oWSH.SpecialFolders("MyDocuments")
>> MsgBox sMyDocuments
>>
>> You can read more about this method here:
>> http://msdn.microsoft.com/en-us/library/0ea7b5xe%28VS.85%29.aspx
>>
>> AFAIK, there is no way to use this method to get the pictures folder.
>> However, you can access this (at least in XP) using the 'Shell Folders'
>> registry key.
>>
>> Set oWSH = CreateObject("WScript.Shell")
>> sKey = "HKCU\Software\Microsoft\Windows\" _
>> & "CurrentVersion\Explorer\Shell Folders\"
>> sMyDocuments = oWSH.RegRead(sKey & "Personal")
>> sMyPictures = oWSH.RegRead(sKey & "My Pictures")
>> MsgBox "Docs:" & vbTab & sMyDocuments & vbLf _
>> & "Pics:" & vbTab & sMyPictures
>
> No, no, BAD dog!
> <http://blogs.msdn.com/b/oldnewthing/archive/2003/11/03/55532.aspx>

The first "value" entry under the key is:

"!Do not use this registry key"="Use the SHGetFolderPath or
SHGetKnownFolderPath function instead"

--
Crash

"The fewer the facts, the stronger the opinion."
~ Arnold H. Glasow ~
From: Kenneth A. Larsen on

"Dave "Crash" Dummy" <invalid(a)invalid.invalid> wrote in message
news:lMV2o.35016$lS1.31785(a)newsfe12.iad...
> How can I address special folders, like "My Documents" and "My Pictures"
> in script? I can address the actual location as indicated in the folder
> shortcut, but that doesn't show up in Explorer. For example, to address
> the image shown in Explorer as "C:\Users\David\My
> Pictures\snapshot.png," I have to look in the "My Pictures" folder
> properties to find the location (C:\Users\David\Pictures) and use that in
> my
> script. Is there some way to address or locate special folders directly?
> --
> Crash
>
> "When you get to a fork in the road, take it."
> ~ Yogi Berra ~

I don't know.