注釋 若 strType 指定了環(huán)境變量所處的位置,可能值為 "System"、"User"、"Volatile" 和 "Process"。若未提供 strType,則該方法在 Windows NT 中檢索系統(tǒng)環(huán)境變量或在 Windows 95 中檢索進程環(huán)境變量。
對于 Windows 95,strType 參數(shù)僅支持 "Process"。
下列變量是由 Windows 操作系統(tǒng)提供的。腳本也可獲取由其他應(yīng)用程序設(shè)置的環(huán)境變量。
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 對象
Windows 95 和 Windows NT 4.0 操作系統(tǒng)提供下列指定文件夾: 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
示例 '' 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