Thursday, January 19, 2006

Find the path to My Documents using VBScript

Set WshShell = Wscript.CreateObject("Wscript.Shell")
path=WshShell.RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal")
Observe that it's Personal that keeps the path to My Documents. This works if the path is below C:\Documents and Settings\ or redirected to a server location like \\server\home$\Jimmy.Bergmark PS. to show code like above I've used HTML code like this. It's useful when the rows are long. Setting the height and width so it fits for the purpose.
<pre style="margin:0px; padding:6px; border:1px #666666 solid; width:600px; 
height:70px; overflow:auto"></pre>

2 comments:

  1. Restored comments

    Dana said...

    I've been trying to figure out a way to display a line of code that can be copied and pasted without deleting superfuous spaces or symbols. How do you do it?
    April 26, 2006

    JTB World said...

    I found that the problem was a setting i blogger. Settings>Formatting>"Convert line breaks" that I had to set to No to have it working as expected. Thanks for your comment. I have now republished the blog so it should be easier to copy code from it.

    If Yes is selected, single hard-returns entered in the Post Editor will be replaced with single < br /> tags in your blog, and two hard-returns will be replaced with two tags (< br />< br />). This also applies to the comment-posting form.
    April 26, 2006

    ReplyDelete
  2. OR

    Set wshshell = CreateObject("WScript.Shell")
    Documents = wshShell.SpecialFolders("MyDocuments")
    wscript.echo Documents


    This can be used for any of the specialfolders.

    ReplyDelete