WshEnvironment 对象未直接给出,可用 WshShell.Environment 属性来访问。
ProgID N/A
文件名 WSHom.Ocx
CLSID
IID
下表描述与 WshEnvironment 对象关联的属性。
属性 说明
Item 获取或设置指定的环境变量值。
Count 枚举项的数目。
length 枚举项的数目 (JScript)。
下表描述与 WshEnvironment 对象关联的方法。
方法 说明
Remove 删除指定的环境变量。
WshShell.SpecialFolders
SpecialFolders 属性提供 WshSpecialFolders 对象以便访问 Windows 的 shell 文件夹,例如桌面文件夹、开始菜单文件夹和个人文档文件夹。
语法
WshShell.SpecialFolders = objWshSpecialFolders
示例
'' This code fragment shows how to access the desktop folder
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")







