WSH Script Shell对象及方法教程
一、 WSH Script Shell对象
二、 WSH Script Shell对象有关的属性方法
1. Shell.Environment
2. Shell.WshEnvironment
3. Shell.SpecialFolders
4. Shell.WshSpecialFolders
5. Shell.CreateShortcut
6. Shell.WshShortcut
7. Shell.WshShortcut.Arguments
8. Shell.WshShortcut.Description
9. Shell.WshShortcut.Hotkey
10. Shell.WshShortcut.IconLocation
11. Shell.WshShortcut.TargetPath
12. Shell.WshShortcut.WindowStyle
13. Shell.WshShortcut.WorkingDirectory
14. Shell.WshShortcut.Save
15. Shell.WshUrlShortcut
16. Shell.WshUrlShortcut.FullName
17. Shell.WshUrlShortcut.TargetPath
18. Shell.WshUrlShortcut.Save
19. Shell.ExpandEnvironmentStrings
20. Shell.Popup
21. Shell.RegDelete
22. Shell.RegRead
23. Shell.RegWrite
24. Shell.Run 12
三、 Wscript.Echo 方法
------------------------------------
一、 WSH Script Shell对象
ProgID Wscript.Shell
文件名 WSHom.Ocx
CLSID F935DC22-1CF0-11d0-ADB9-00C04FD58A0B
IID F935DC21-1CF0-11d0-ADB9-00C04FD58A0B
Set Shell=CreateObject(Wscript.Shell)
下表说明和 Wscript Shell 对象有关的属性。
属性 说明
Environment 返回 WshEnvironment 集合对象。
SpecialFolders 使用 WshSpecialFolders 对象提供对 Windows shell 文件夹 的访问,如桌面文件夹,开始菜单文件夹和个人文档文件夹。
下表说明和 Wscript Shell 对象有关的方法。
方法 说明
CreateShortcut 创建并返回 WshShortcut 对象。
ExpandEnvironmentStrings 扩展 PROCESS 环境变量并返回结果字符串。
Popup 显示包含指定消息的消息窗口。
RegDelete 从注册表中删除指定的键或值。
RegRead 从注册表中返回指定的键或值。
RegWrite 在注册表中设置指定的键或值。
Run 创建新的进程,该进程用指定的窗口样式执行指定的命令。
二、 WSH Script Shell对象有关的属性方法
1. Shell.Environment
Environment 属性返回 WshEnvironment 对象。
语法
Shell.Environment ( [strType]) = objWshEnvironment
注释
若 strType 指定了环境变量所处的位置,可能值为 "System"、"User"、"Volatile" 和 "Process"。若未提供 strType,则该方法在 Windows NT 中检索系统环境变量或在 Windows 95 中检索进程环境变量。
对于 Windows 95,strType 参数仅支持 "Process"。
下列变量是由 Windows 操作系统提供的。脚本也可获取由其他应用程序设置的环境变量。
环境变量
NUMBER_OF_PROCESSORS 计算机上运行的处理器数目。
PROCESSOR_ARCHITECTURE 用户工作站使用的处理器类型。
一、 WSH Script Shell对象
二、 WSH Script Shell对象有关的属性方法
1. Shell.Environment
2. Shell.WshEnvironment
3. Shell.SpecialFolders
4. Shell.WshSpecialFolders
5. Shell.CreateShortcut
6. Shell.WshShortcut
7. Shell.WshShortcut.Arguments
8. Shell.WshShortcut.Description
9. Shell.WshShortcut.Hotkey
10. Shell.WshShortcut.IconLocation
11. Shell.WshShortcut.TargetPath
12. Shell.WshShortcut.WindowStyle
13. Shell.WshShortcut.WorkingDirectory
14. Shell.WshShortcut.Save
15. Shell.WshUrlShortcut
16. Shell.WshUrlShortcut.FullName
17. Shell.WshUrlShortcut.TargetPath
18. Shell.WshUrlShortcut.Save
19. Shell.ExpandEnvironmentStrings
20. Shell.Popup
21. Shell.RegDelete
22. Shell.RegRead
23. Shell.RegWrite
24. Shell.Run 12
三、 Wscript.Echo 方法
------------------------------------
一、 WSH Script Shell对象
ProgID Wscript.Shell
文件名 WSHom.Ocx
CLSID F935DC22-1CF0-11d0-ADB9-00C04FD58A0B
IID F935DC21-1CF0-11d0-ADB9-00C04FD58A0B
Set Shell=CreateObject(Wscript.Shell)
下表说明和 Wscript Shell 对象有关的属性。
属性 说明
Environment 返回 WshEnvironment 集合对象。
SpecialFolders 使用 WshSpecialFolders 对象提供对 Windows shell 文件夹 的访问,如桌面文件夹,开始菜单文件夹和个人文档文件夹。
下表说明和 Wscript Shell 对象有关的方法。
方法 说明
CreateShortcut 创建并返回 WshShortcut 对象。
ExpandEnvironmentStrings 扩展 PROCESS 环境变量并返回结果字符串。
Popup 显示包含指定消息的消息窗口。
RegDelete 从注册表中删除指定的键或值。
RegRead 从注册表中返回指定的键或值。
RegWrite 在注册表中设置指定的键或值。
Run 创建新的进程,该进程用指定的窗口样式执行指定的命令。
二、 WSH Script Shell对象有关的属性方法
1. Shell.Environment
Environment 属性返回 WshEnvironment 对象。
语法
Shell.Environment ( [strType]) = objWshEnvironment
注释
若 strType 指定了环境变量所处的位置,可能值为 "System"、"User"、"Volatile" 和 "Process"。若未提供 strType,则该方法在 Windows NT 中检索系统环境变量或在 Windows 95 中检索进程环境变量。
对于 Windows 95,strType 参数仅支持 "Process"。
下列变量是由 Windows 操作系统提供的。脚本也可获取由其他应用程序设置的环境变量。
环境变量
NUMBER_OF_PROCESSORS 计算机上运行的处理器数目。
PROCESSOR_ARCHITECTURE 用户工作站使用的处理器类型。