WshShortcut Object This object is not exposed directly. To get the WshShortcut object, use the WshShell.CreateShortcut method.
|
ProgID |
N/A |
|
Filename |
WSHom.Ocx |
|
CLSID |
F935DC28-1CF0-11d0-ADB9-00C04FD58A0B |
|
IID |
F935DC27-1CF0-11d0-ADB9-00C04FD58A0B |
The following table describes the properties associated with the WshShortcut object.
|
Property |
Description |
|
Arguments |
Parameters to a shortcut object. |
|
Description |
A description of a shortcut object. |
|
Hotkey |
The hotkey of a shortcut object. |
|
IconLocation |
The icon location of a shortcut object. |
|
TargetPath |
The target path of a shortcut object. |
|
WindowStyle |
The window style of a shortcut object. |
|
WorkingDirectory |
The working directory of a shortcut object. |
The following table describes the method associated with the WshShortcut object.
|
Method |
Description |
|
Save |
Saves a shortcut into a specified file system. |
WshShortcut.Arguments
The Arguments property
provides parameters to a shortcut object.
Syntax
WshShortcut.Arguments = strArguments
WshShortcut.Description
The Description property
provides a description of a shortcut object.
Syntax
WshShortcut.Description = strDescription
WshShortcut.FullName
The FullName property
provides the full path of a shortcut object.
set WshShell = WScript.CreateObject("WScript.Shell")
set fso = WScript.CreateObject("Scripting.FileSystemObject")
strPrograms = WshShell.SpecialFolders("AllUsersPrograms")
EnumShortcuts fso.GetFolder(strPrograms)
strPrograms = WShShell.SpecialFolders("Programs")
EnumShortcuts fso.GetFolder(strPrograms)
function GetExt(filename)
dim p
p = InStrRev(filename, ".")
if p > 0 then
GetExt = Mid(filename, p)
else
GetExt = ""
end if
end function
sub PrintShortCut(filename)
dim oShellLink
set oShellLink = WshShell.CreateShortcut(filename)
WScript.Echo "File: " & filename
WScript.Echo "Description: " & oShellLink.Description
WScript.Echo "Target: " & oShellLink.TargetPath
WScript.Echo
end sub
sub EnumShortcuts(folder)
dim file, subFolder
for each file in folder.Files
if LCase(GetExt(file.Name)) = ".lnk" then
PrintShortCut file.Path
end if
next
for each subFolder in folder.SubFolders
EnumShortcuts(subFolder)
next
end sub
//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE
"j. koudijs" <janko...@hccnet.nl> ???????/???????? ? ???????? ?????????:
news:4056d64d$1$2822$3a62...@reader1.nntp.hccnet.nl...
>dim WshShell, fso, strPrograms
>
>set WshShell = WScript.CreateObject("WScript.Shell")
>set fso = WScript.CreateObject("Scripting.FileSystemObject")
>
>strPrograms = WshShell.SpecialFolders("AllUsersPrograms")
>EnumShortcuts fso.GetFolder(strPrograms)
>
>strPrograms = WShShell.SpecialFolders("Programs")
>EnumShortcuts fso.GetFolder(strPrograms)
>
Thank you,
for that nice script. For those modying the standard install (like me)
it might be helpful to use:
strPrograms = WshShell.SpecialFolders("AllUsersStartMenu")
and
strPrograms = WShShell.SpecialFolders("StartMenu")
Do you know how to get the names of all the special folders?
I was able to enumerate them with this script:
dim WshShell, fso, strPrograms
dim file, Folder
set WshShell = WScript.CreateObject("WScript.Shell")
set fso = WScript.CreateObject("Scripting.FileSystemObject")
for each Folder in WshShell.SpecialFolders
WScript.Echo Folder
next
But how to obtain the name orindex ?
--
Greetings
Matthias
Looking in documentation:
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
//------------------------------------
Regards,
Vassiliev V. V.
http://www-sharp.com -
Scripting/HTA/.Net Framework IDE
"Matthias Tacke" <Matt...@Tacke.de> ???????/???????? ? ???????? ?????????:
news:c3737t$aka$00$1...@news.t-online.com...
> The following special folders are available:
>
> AllUsersDesktop
> AllUsersStartMenu
> AllUsersPrograms
> AllUsersStartup
> Desktop
> Favorites
> Fonts
> MyDocuments
> NetHood
> PrintHood
> Programs
> Recent
> SendTo
> StartMenu
> Startup
> Templates
Hi
You can add AppData to that list - undocumented but it works
on Win2K and higher.
With WSH FileSystemObject's GetSpecialFolder method, you can also
get to the Windows folder, Windows system folder and temp folder:
Set oFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = oFSO.GetSpecialFolder(0)
sWinSysDir = oFSO.GetSpecialFolder(1)
sTempDir = oFSO.GetSpecialFolder(2)
--
torgeir
Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of the 1328 page
Scripting Guide:
http://www.microsoft.com/technet/community/scriptcenter/default.mspx
"Torgeir Bakken (MVP)" <Torgeir.B...@hydro.com> wrote in message
news:40572029...@hydro.com...
> "Viatcheslav V. Vassiliev" wrote:
>
> > The following special folders are available:
> >
> > AllUsersDesktop
> > AllUsersStartMenu
> > AllUsersPrograms
> > AllUsersStartup
> > Desktop
> > Favorites
> > Fonts
> > MyDocuments
> > NetHood
> > PrintHood
> > Programs
> > Recent
> > SendTo
> > StartMenu
> > Startup
> > Templates
>
> Hi
>
> You can add AppData to that list - undocumented but it works
> on Win2K and higher.
Also note the oFso.GetSpecialFolder collection, which contains folder paths
not available in other collections:
---
set oFso= createobject("scripting.fileSystemObject")
sFolderPathName= oFso.getSpecialFolder(<integer code>)
'0=windows folder
'1=system folder
'2= current temporary folder
---
On Shell5 (Win2k/Me/Xp), you can also use the shell folders collection,
which has many more defined folders. The number depends on both the version
of Windows and your particular installation. (Actually, you can use it on
pre-Shell5 versions of Windows, if use a substitute routine for the Self
property, but it's far less comprehensive on those systems.)
---
set oShell= createobject("shell.application")
sFolder= shellApp.namespace(<integer code>).self.path
---
The following is a very useful utility HTM script that Michael Harris kindly
wrote and posted some time back, that will enumerate all the shell folders
available on a particular host computer. Uses the Self property and
requires Shell5 (Win2k/Me/Xp).
---
<html>
<head><title>Shell Special Folders</title>
<script language="vbscript">
sub window_onload()
Set shellApp = CreateObject("Shell.Application")
Set CSIDL_VALUES = CreateObject("Scripting.Dictionary")
CSIDL_VALUES.Add "CSIDL_ADMINTOOLS", &H30
CSIDL_VALUES.Add "CSIDL_ALTSTARTUP", &H1D
CSIDL_VALUES.Add "CSIDL_APPDATA", &H1A
CSIDL_VALUES.Add "CSIDL_BITBUCKET", &HA
CSIDL_VALUES.Add "CSIDL_CDBURN_AREA", &H3B
CSIDL_VALUES.Add "CSIDL_COMMON_ADMINTOOLS", &H2F
CSIDL_VALUES.Add "CSIDL_COMMON_ALTSTARTUP", &H1E
CSIDL_VALUES.Add "CSIDL_COMMON_APPDATA", &H23
CSIDL_VALUES.Add "CSIDL_COMMON_DESKTOPDIRECTORY", &H19
CSIDL_VALUES.Add "CSIDL_COMMON_DOCUMENTS", &H2E
CSIDL_VALUES.Add "CSIDL_COMMON_FAVORITES", &H1F
CSIDL_VALUES.Add "CSIDL_COMMON_MUSIC", &H35
CSIDL_VALUES.Add "CSIDL_COMMON_OEM_LINKS", &H3A
CSIDL_VALUES.Add "CSIDL_COMMON_PICTURES", &H36
CSIDL_VALUES.Add "CSIDL_COMMON_PROGRAMS", &H17
CSIDL_VALUES.Add "CSIDL_COMMON_STARTMENU", &H16
CSIDL_VALUES.Add "CSIDL_COMMON_STARTUP", &H18
CSIDL_VALUES.Add "CSIDL_COMMON_TEMPLATES", &H2D
CSIDL_VALUES.Add "CSIDL_COMMON_VIDEO", &H37
CSIDL_VALUES.Add "CSIDL_COMPUTERSNEARME", &H3D
CSIDL_VALUES.Add "CSIDL_CONNECTIONS", &H31
CSIDL_VALUES.Add "CSIDL_CONTROLS", &H3
CSIDL_VALUES.Add "CSIDL_COOKIES", &H21
CSIDL_VALUES.Add "CSIDL_DESKTOP", &H0
CSIDL_VALUES.Add "CSIDL_DESKTOPDIRECTORY", &H10
CSIDL_VALUES.Add "CSIDL_DRIVES", &H11
CSIDL_VALUES.Add "CSIDL_FAVORITES", &H6
CSIDL_VALUES.Add "CSIDL_FLAG_CREATE", &H8000
CSIDL_VALUES.Add "CSIDL_FLAG_DONT_VERIFY", &H4000
CSIDL_VALUES.Add "CSIDL_FLAG_MASK", &HFF00
CSIDL_VALUES.Add "CSIDL_FLAG_NO_ALIAS", &H1000
CSIDL_VALUES.Add "CSIDL_FLAG_PER_USER_INIT", &H800
CSIDL_VALUES.Add "CSIDL_FONTS", &H14
CSIDL_VALUES.Add "CSIDL_HISTORY", &H22
CSIDL_VALUES.Add "CSIDL_INTERNET", &H1
CSIDL_VALUES.Add "CSIDL_INTERNET_CACHE", &H20
CSIDL_VALUES.Add "CSIDL_LOCAL_APPDATA", &H1C
CSIDL_VALUES.Add "CSIDL_MYDOCUMENTS", &HC
CSIDL_VALUES.Add "CSIDL_MYMUSIC", &HD
CSIDL_VALUES.Add "CSIDL_MYPICTURES", &H27
CSIDL_VALUES.Add "CSIDL_MYVIDEO", &HE
CSIDL_VALUES.Add "CSIDL_NETHOOD", &H13
CSIDL_VALUES.Add "CSIDL_NETWORK", &H12
CSIDL_VALUES.Add "CSIDL_PERSONAL", &H5
CSIDL_VALUES.Add "CSIDL_PRINTERS", &H4
CSIDL_VALUES.Add "CSIDL_PRINTHOOD", &H1B
CSIDL_VALUES.Add "CSIDL_PROFILE", &H28
CSIDL_VALUES.Add "CSIDL_PROGRAM_FILES", &H26
CSIDL_VALUES.Add "CSIDL_PROGRAM_FILES_COMMON", &H2B
CSIDL_VALUES.Add "CSIDL_PROGRAM_FILES_COMMONX86", &H2C
CSIDL_VALUES.Add "CSIDL_PROGRAM_FILESX86", &H2A
CSIDL_VALUES.Add "CSIDL_PROGRAMS", &H2
CSIDL_VALUES.Add "CSIDL_RECENT", &H8
CSIDL_VALUES.Add "CSIDL_RESOURCES", &H38
CSIDL_VALUES.Add "CSIDL_RESOURCES_LOCALIZED", &H39
CSIDL_VALUES.Add "CSIDL_SENDTO", &H9
CSIDL_VALUES.Add "CSIDL_STARTMENU", &HB
CSIDL_VALUES.Add "CSIDL_STARTUP", &H7
CSIDL_VALUES.Add "CSIDL_SYSTEM", &H25
CSIDL_VALUES.Add "CSIDL_SYSTEMX86", &H29
CSIDL_VALUES.Add "CSIDL_TEMPLATES", &H15
CSIDL_VALUES.Add "CSIDL_WINDOWS", &H24
s = "<table border=1 cellspacing=0>"
For Each key In CSIDL_VALUES.Keys
value = "*** not available ***"
On Error Resume Next
value = shellApp.Namespace(CSIDL_VALUES.Item(key)).Self.Path
On Error GoTo 0
s = s & "<tr>"
s = s & "<td>" & key & "</td>"
s = s & "<td>&H" & hex(CSIDL_VALUES.Item(key)) & "</td>"
s = s & "<td nowrap>" & value & "</td>"
s = s & "</tr>"
Next
s = s & "</table>"
document.body.innerHtml = s
end sub
</script>
<style>
table
{
font:10pt verdana;
}
tr
{
text-align:left;
vertical-align:top;
padding:5px;
}
td
{
padding:5px;
}
</style>
<body>
</body>
</html>
---
Joe Earnest
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.564 / Virus Database: 356 - Release Date: 01-19-04
Thanks Torgeir and Viatcheslav
--
Greetings
Matthias
Gr. Jan
"Viatcheslav V. Vassiliev" <msnew...@www-sharp.com> schreef in bericht
news:OvojVp0C...@TK2MSFTNGP12.phx.gbl...