From: "Dave "Crash" Dummy" on
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 ~
From: James Whitlow 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?

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


From: "Dave "Crash" Dummy" on
James Whitlow 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? 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

Thank you. I discovered the SpecialFolders code, and the fact that it
doesn't apply to the "MyPictures" folder. I will poke around the Windows
7 registry.
--
Crash

"The future ain't what it used to be."
~ Yogi Berra ~
From: Stefan Kanthak on
"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>

Stefan

From: Al Dunbar on


"Stefan Kanthak" <postmaster@[127.0.0.1]> wrote in message
news:eAf1NmDLLHA.4312(a)TK2MSFTNGP02.phx.gbl...
> "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

Nice, thanks...

>>> 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>

Nice narrative, thanks again.

/Al