主頁 > 知識(shí)庫 > Wscript.Shell 對(duì)象詳細(xì)介紹!!特好的東西第1/2頁

Wscript.Shell 對(duì)象詳細(xì)介紹??!特好的東西第1/2頁

熱門標(biāo)簽:美圖手機(jī) 檢查注冊(cè)表項(xiàng) 鐵路電話系統(tǒng) 呼叫中心市場(chǎng)需求 智能手機(jī) 網(wǎng)站文章發(fā)布 銀行業(yè)務(wù) 服務(wù)器配置
分類:程序
WshShell 對(duì)象
ProgID Wscript.Shell
文件名 WSHom.Ocx
CLSID F935DC22-1CF0-11d0-ADB9-00C04FD58A0B
IID F935DC21-1CF0-11d0-ADB9-00C04FD58A0B


下表說明和 WshShell 對(duì)象有關(guān)的屬性。

屬性 說明
Environment 返回 WshEnvironment 集合對(duì)象。
SpecialFolders 使用 WshSpecialFolders 對(duì)象提供對(duì) Windows shell 文件夾的訪問,如桌面文件夾,開始菜單文件夾和個(gè)人文檔文件夾。


下表說明和 WshShell 對(duì)象有關(guān)的方法。

方法 說明
CreateShortcut 創(chuàng)建并返回 WshShortcut 對(duì)象。
ExpandEnvironmentStrings 擴(kuò)展 PROCESS 環(huán)境變量并返回結(jié)果字符串。
Popup 顯示包含指定消息的消息窗口。
RegDelete 從注冊(cè)表中刪除指定的鍵或值。
RegRead 從注冊(cè)表中返回指定的鍵或值。
RegWrite 在注冊(cè)表中設(shè)置指定的鍵或值。
Run 創(chuàng)建新的進(jìn)程,該進(jìn)程用指定的窗口樣式執(zhí)行指定的命令。


WshShell.Environment
Environment 屬性返回 WshEnvironment 對(duì)象。

語法
WshShell.Environment ( [strType]) = objWshEnvironment

注釋
若 strType 指定了環(huán)境變量所處的位置,可能值為 "System"、"User"、"Volatile" 和 "Process"。若未提供 strType,則該方法在 Windows NT 中檢索系統(tǒng)環(huán)境變量或在 Windows 95 中檢索進(jìn)程環(huán)境變量。

對(duì)于 Windows 95,strType 參數(shù)僅支持 "Process"。

下列變量是由 Windows 操作系統(tǒng)提供的。腳本也可獲取由其他應(yīng)用程序設(shè)置的環(huán)境變量。

名稱 說明
NUMBER_OF_PROCESSORS 計(jì)算機(jī)上運(yùn)行的處理器數(shù)目。
PROCESSOR_ARCHITECTURE 用戶工作站使用的處理器類型。
PROCESSOR_IDENTIFIER 用戶工作站的處理器 ID。
PROCESSOR_LEVEL 用戶工作站的處理器級(jí)。
PROCESSOR_REVISION 用戶工作站的處理器版本。
OS 用戶工作站所用的操作系統(tǒng)。
COMSPEC 用于運(yùn)行“命令提示”窗口的命令(通常為 cmd.exe)。
HOMEDRIVE 本地主驅(qū)動(dòng)器(通常為 C 驅(qū)動(dòng)器)。
HOMEPATH 用戶的默認(rèn)路徑(在 Windows NT 上通常為 usersdefault)。
PATH 路徑環(huán)境變量。
PATHEXT 可執(zhí)行文件的擴(kuò)展名(通常為 .com、 .exe、.bat 或 .cmd)。
PROMPT 命令提示符(通常為 $P$G)。
SYSTEMDRIVE 系統(tǒng)所在的本地驅(qū)動(dòng)器(例如,c:)。
SYSTEMROOT 系統(tǒng)目錄(例如,c:winnt)。和 WINDIR 相同。
WINDIR 系統(tǒng)目錄(例如 c:winnt)。和 SYSTEMROOT 相同。
TEMP 存儲(chǔ)臨時(shí)文件的目錄(例如,c:temp)。用戶可更改。
TMP 存儲(chǔ)臨時(shí)文件的目錄(例如,c:temp)。用戶可更改。


示例
'' Retrieve the NUMBER_OF_PROCESSORS system environment variable
Set WshShell = Wscript.CreateObject("Wscript.Shell")

Set WshSysEnv = WshShell.Environment("SYSTEM")
Wscript.Echo WshSysEnv("NUMBER_OF_PROCESSORS")

請(qǐng)參閱
WshEnvironment 對(duì)象


WshEnvironment 對(duì)象
WshEnvironment 對(duì)象未直接給出,可用 WshShell.Environment 屬性來訪問。

ProgID N/A
文件名 WSHom.Ocx
CLSID
IID


下表描述與 WshEnvironment 對(duì)象關(guān)聯(lián)的屬性。

屬性 說明
Item 獲取或設(shè)置指定的環(huán)境變量值。
Count 枚舉項(xiàng)的數(shù)目。
length 枚舉項(xiàng)的數(shù)目 (JScript)。


下表描述與 WshEnvironment 對(duì)象關(guān)聯(lián)的方法。

方法 說明
Remove 刪除指定的環(huán)境變量。


WshShell.SpecialFolders
SpecialFolders 屬性提供 WshSpecialFolders 對(duì)象以便訪問 Windows 的 shell 文件夾,例如桌面文件夾、開始菜單文件夾和個(gè)人文檔文件夾。

語法
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")
請(qǐng)參閱
WshSpecialFolders 對(duì)象

WshSpecialFolders 對(duì)象
該對(duì)象未直接給出。要得到 WshSpecialFolders 對(duì)象,請(qǐng)使用 WshShell.SpecialFolders 屬性。

ProgID N/A
文件名 WSHom.Ocx
CLSID
IID


下表描述與 WshSpecialFolders 對(duì)象關(guān)聯(lián)的屬性。

屬性 描述
Item 指定文件夾的完整路徑(默認(rèn))。
Count 枚舉項(xiàng)的數(shù)目。
length 枚舉項(xiàng)的數(shù)目 (JScript) 。

WshSpecialFolders.Item
Item 屬性返回由 strFolderName 指定的文件夾的完整路徑。它是默認(rèn)屬性。

語法
WshShell.SpecialFolders.Item("strFolderName") = strFolderPath
WshShell.SpecialFolders("strFolderName") = strFolderPath

注釋
若請(qǐng)求的文件夾 (strFolderName) 不可用,則 WshShell.SpecialFolders("strFolderName") 返回 NULL。例如,Windows 95 沒有 AllUsersDesktop 文件夾,如果 strFolderName = AllUsersDesktop,則返回 NULL。

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

請(qǐng)參閱
WshShell.SpecialFolders 屬性


WshShell.CreateShortcut
CreateShortcut 方法創(chuàng)建 WshShortcut 對(duì)象并將其返回。如果快捷方式標(biāo)題以 .url 結(jié)尾,就會(huì)創(chuàng)建 WshURLShortcut 對(duì)象。

語法
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

請(qǐng)參閱
WshShortcut 對(duì)象、WshUrlShortcut 對(duì)象

WshShortcut 對(duì)象
該對(duì)象未直接給出。要獲得 WshShortcut 對(duì)象,請(qǐng)使用 WshShell.CreateShortcut 方法。

ProgID N/A
文件名 WSHom.Ocx
CLSID F935DC28-1CF0-11d0-ADB9-00C04FD58A0B
IID F935DC27-1CF0-11d0-ADB9-00C04FD58A0B


下表說明和 WshShortcut 對(duì)象有關(guān)的屬性。

屬性 說明
Arguments 快捷方式對(duì)象的參數(shù)。
Description 快捷方式對(duì)象的說明。
Hotkey 快捷方式對(duì)象的熱鍵。
IconLocation 快捷方式對(duì)象的圖標(biāo)位置。
TargetPath 快捷方式對(duì)象的目標(biāo)路徑。
WindowStyle 快捷方式對(duì)象的窗口樣式。
WorkingDirectory 快捷方式對(duì)象的工作目錄。


下表說明與 WshShortcut 對(duì)象有關(guān)的方法。

方法 說明
Save 將快捷方式存儲(chǔ)到指定的文件系統(tǒng)中。

WshShortcut.Arguments
Arguments 屬性提供快捷方式對(duì)象的參數(shù)。

語法
WshShortcut.Arguments = strArguments

WshShortcut.Description
Description 屬性提供快捷方式對(duì)象的說明。

語法
WshShortcut.Description = strDescription

WshShortcut.Hotkey
HotKey 屬性提供快捷方式對(duì)象的熱鍵。熱鍵是啟動(dòng)或切換程序的鍵盤快捷方式。

語法
WshShortcut.HotKey = strHotKey

注釋
strHotKey 的BNF語法如下:

Hotkey ::= modifier* keyname
modifier ::= "ALT+" | "CTRL+" | "SHIFT+" | "EXT+"
keyname ::= "A" .. "Z" |
"0".. "9" |
"Back" | "Tab" | "Clear" | "Return" |
"Escape" | "Space" | "Prior" | ...

所有鍵的名稱都可以在 WINUSER.H 中找到。熱鍵不區(qū)分大小寫。

熱鍵只能激活位于 Windows 桌面或 Windows“開始”菜單的快捷方式。

Windows 資源管理器不接受 ESC、ENTER、TAB、SPACE、PRINT SCREEN 或 BACKSPACE,即使 WshShortcut.Hotkey 遵循 Win32 API 支持它們。因此,建議在快捷方式中不要用這些鍵。

示例
Set WshShell = Wscript.CreateObject("Wscript.WshShell")
strDesktop = WshShell.SpecialFolders("Desktop")
Set oMyShortcut = WshShell.CreateShortcut(strDesktop "a_key.lnk")
OMyShortcut.TargetPath = "%windir%notepad.exe"
oMyShortCut.Hotkey = "ALT+CTRL+F"
oMyShortCut.Save
Wscript.Echo oMyShortCut.HotKey = "Alt+Ctrl+F"

請(qǐng)參閱
WshSpecialFolders 對(duì)象

WshShortcut.IconLocation
IconLocation 屬性提供快捷方式對(duì)象的圖標(biāo)位置。圖標(biāo)位置的格式應(yīng)為 "Path,index"。

語法
WshShortcut.IconLocation = strIconLocation

WshShortcut.TargetPath
TargetPath 屬性提供快捷方式對(duì)象的目標(biāo)路徑。

語法
WshShortcut.TargetPath = strTargetPath

WshShortcut.WindowStyle
WindowStyle 屬性提供快捷方式對(duì)象的窗口樣式。

語法
WshShortcut.WindowStyle = natWindowStyle

WshShortcut.WorkingDirectory
WorkingDirectory 為一個(gè)快捷方式對(duì)象提供工作目錄。

語法
WshShortcut.WorkingDirectory = strWorkingDirectory

WshShortcut.Save
Save 方法把快捷方式對(duì)象保存到由 FullName 屬性指定的位置。

語法
WshShortcut.Save

WshUrlShortcut 對(duì)象
該對(duì)象未直接給出。要獲取 WshUrlShortcut 對(duì)象,可使用 WshShell.CreateShortcut 方法。

ProgID N/A
文件名 WSHom.Ocx
CLSID
IID

12下一頁閱讀全文
您可能感興趣的文章:
  • windows2003下使用asp WScript.Shell的設(shè)置方法
  • ASP.NET下使用WScript.Shell執(zhí)行命令
  • vbScript中WScript.Shell對(duì)象的run和exec使用心得分享
  • 關(guān)閉網(wǎng)站的wscript.shell命令行執(zhí)行
  • 利用WScript.Shell對(duì)象隱藏cmd命令行運(yùn)行框的實(shí)現(xiàn)代碼
  • win2003 WScript.shell與Shell組件安全篇
  • WScript.Shell對(duì)象SpecialFolders屬性未公開文檔分享
  • Js使用WScript.Shell對(duì)象執(zhí)行.bat文件和cmd命令

標(biāo)簽:紅河 長(zhǎng)治 河南 滄州 新疆 樂山 沈陽 上海

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Wscript.Shell 對(duì)象詳細(xì)介紹?。√睾玫臇|西第1/2頁》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266