Stream、WshShell、WshUrlShortcut对象及Shell.Application的参数与使用

2019-01-16 10:56:27于丽

Set WshShell = Wscript.CreateObject("Wscript.Shell")
MsgBox "Your desktop is " & WshShell.SpecialFolders("Desktop")
请参阅
WshSpecialFolders 对象
WshSpecialFolders 对象
该对象未直接给出。要得到 WshSpecialFolders 对象,请使用 WshShell.SpecialFolders 属性。
ProgID N/A 
文件名 WSHom.Ocx 
CLSID 
IID 
下表描述与 WshSpecialFolders 对象关联的属性。 
属性 描述 
Item 指定文件夹的完整路径(默认)。 
Count 枚举项的数目。 
length 枚举项的数目 (JScript) 。 
WshSpecialFolders.Item
Item 属性返回由 strFolderName 指定的文件夹的完整路径。它是默认属性。
语法
WshShell.SpecialFolders.Item("strFolderName") = strFolderPath
WshShell.SpecialFolders("strFolderName") = strFolderPath
注释
若请求的文件夹 (strFolderName) 不可用,则 WshShell.SpecialFolders("strFolderName") 返回 NULL。例如,Windows 95 没有 AllUsersDesktop 文件夹,如果 strFolderName = AllUsersDesktop,则返回 NULL。
Windows 95 和 Windows NT 4.0 操作系统提供下列指定文件夹: 
AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup
Templates
示例
' This fragment returns the full path for the Windows Desktop folder
Set WshShell = Wscript.CreateObject("Wscript.Shell")
StrMyDesktop = WshShell.SpecialFolders("Desktop")
' List all special folders
For Each strFolder In WshShell.SpecialFolders
MsgBox strFolder
Next
请参阅
WshShell.SpecialFolders 属性 
WshShell.CreateShortcut
CreateShortcut 方法创建 WshShortcut 对象并将其返回。如果快捷方式标题以 .url 结尾,就会创建 WshURLShortcut 对象。
语法
WshShell.CreateShortcut(strPathname) = objShortcut
示例
' This code fragment creates a shortcut 
' to the currently executing script
Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set oShellLink = WshShell.CreateShortcut("Current Script.lnk")
oShellLink.TargetPath = Wscript.ScriptFullName
oShellLink.Save
Set oUrlLink = WshShell.CreateShortcut("Microsoft Web Site.URL")
oUrlLink.TargetPath = "http://www.microsoft.com"
oUrlLink.Save
请参阅
WshShortcut 对象、WshUrlShortcut 对象