6 out of 8 rated this helpful - Rate this topic

SpecialFolders Property

Returns a SpecialFolders object (a collection of special folders).

object.SpecialFolders(objWshSpecialFolders) 
object

WshShell object.

objWshSpecialFolders

The name of the special folder.

The WshSpecialFolders object is a collection. It contains the entire set of Windows special folders, such as the Desktop folder, the Start Menu folder, and the Personal Documents folder. The special folder name is used to index into the collection to retrieve the special folder you want. The SpecialFolders property returns an empty string if the requested folder (strFolderName) is not available. For example, Windows 95 does not have an AllUsersDesktop folder and returns an empty string if strFolderNameis AllUsersDesktop.

The following special folders are available:

  • AllUsersDesktop

  • AllUsersStartMenu

  • AllUsersPrograms

  • AllUsersStartup

  • Desktop

  • Favorites

  • Fonts

  • MyDocuments

  • NetHood

  • PrintHood

  • Programs

  • Recent

  • SendTo

  • StartMenu

  • Startup

  • Templates

Description

The following example demonstrates the use of the SpecialFolders property:

<package>
   <job id="vbs">
      <script language="VBScript">
         set WshShell = WScript.CreateObject("WScript.Shell")
         strDesktop = WshShell.SpecialFolders("Desktop")
         set oShellLink = WshShell.CreateShortcut(strDesktop & "\Shortcut Script.lnk")
         oShellLink.TargetPath = WScript.ScriptFullName
         oShellLink.WindowStyle = 1
         oShellLink.Hotkey = "Ctrl+Alt+e"
         oShellLink.IconLocation = "notepad.exe, 0"
         oShellLink.Description = "Shortcut Script"
         oShellLink.WorkingDirectory = strDesktop
         oShellLink.Save
         set oUrlLink = WshShell.CreateShortcut(strDesktop & "\Microsoft Web Site.url")
         oUrlLink.TargetPath = "http://www.microsoft.com"
         oUrlLink.Save
      </script>
   </job>

   <job id="js">
      <script language="JScript">
         var WshShell = WScript.CreateObject("WScript.Shell");
         strDesktop = WshShell.SpecialFolders("Desktop");
         var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut Script.lnk");
         oShellLink.TargetPath = WScript.ScriptFullName;
         oShellLink.WindowStyle = 1;
         oShellLink.Hotkey = "Ctrl+Alt+e";
         oShellLink.IconLocation = "notepad.exe, 0";
         oShellLink.Description = "Shortcut Script";
         oShellLink.WorkingDirectory = strDesktop;
         oShellLink.Save();
         var oUrlLink = WshShell.CreateShortcut(strDesktop + "\\Microsoft Web Site.url");
         oUrlLink.TargetPath = "http://www.microsoft.com";
         oUrlLink.Save();
      </script>
   </job>
</package>

Applies To:

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Special Folders Sample, but using PowerShell
&lt;#
.SYNOPSIS
This script creates a shortcut to Notepad on the Desktop
.DESCRIPTION
This script creates a Wscript.shell item, then creates
a shortcut on the desktop to Notepad.exe.
.LINKS
This post is a re-implementation of an MSDN Script
http://msdn.microsoft.com/en-us/library/0ea7b5xe%28VS.85%29.aspx
Posted to PowerShell Scripts Blog
HTTP://Pshscripts.blogspot.com
.EXAMPLE
Left as an exercise for the reader
#&gt;

# create wscript object
$WshShell = New-Object -com WScript.Shell

#Get Desktop location
$Desktop = $WshShell.SpecialFolders.item("Desktop")

# create a new shortcut
$ShellLink = $WshShell.CreateShortcut($Desktop + "\Shortcut Script.lnk")
$ShellLink.TargetPath = $WScript.ScriptFullName
$ShellLink.WindowStyle = 1
$ShellLink.Hotkey = "CTRL+SHIFT+F"
$ShellLink.IconLocation = "notepad.exe, 0"
$ShellLink.Description = "Shortcut Script"
$ShellLink.WorkingDirectory = $Desktop

#Save the link to the desktop
$ShellLink.Save()