If ComputerOption(0).Checked Then strComputer = ComputerOption(0).Value End If If ComputerOption(1).Checked Then strComputer = ComputerOption(1).Value End If If ComputerOption(2).Checked Then strComputer = ComputerOption(2).Value End If If ComputerOption(3).Checked Then strComputer = ComputerOption(3).Value End If
If strComputer = "" Then Exit Sub End If
Set objWMIService = GetObject _ ("winmgmts://" & strComputer & "/root/cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_OperatingSystem") For Each objItem in ColItems Msgbox objItem.Caption Next
那么該代碼包含哪些內(nèi)容呢?我們可以將該代碼分為四部分:其中有兩個(gè)部分使用 HTML 標(biāo)記來(lái)實(shí)現(xiàn)單選按鈕以及“Run Script(運(yùn)行腳本)”和“Cancel(取消)”按鈕,而另外兩個(gè)部分則根據(jù)您所點(diǎn)擊的是“Run Script”還是“Cancel”來(lái)運(yùn)行子例程。讓我們更進(jìn)一步了解這幾個(gè)部分。
例如,HTML 代碼在此顯示這四個(gè)單選按鈕。(如果您了解 HTML,那么這里就沒(méi)有什么特別的;這是標(biāo)準(zhǔn)的 HTML 編碼。)請(qǐng)注意,所有按鈕都有相同的名稱 (ComputerOption);這是為了確保一次只能選擇一個(gè)按鈕。還要注意,每個(gè)按鈕的“值”都被設(shè)為相應(yīng)計(jì)算機(jī)的名稱:
If ComputerOption(0).Checked Then strComputer = ComputerOption(0).Value End If If ComputerOption(1).Checked Then strComputer = ComputerOption(1).Value End If If ComputerOption(2).Checked Then strComputer = ComputerOption(2).Value End If If ComputerOption(3).Checked Then strComputer = ComputerOption(3).Value End If
If strComputer = "" Then Exit Sub End If
Set objWMIService = GetObject _ ("winmgmts://" & strComputer & "/root/cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_OperatingSystem") For Each objItem in ColItems Msgbox objItem.Caption Next
If ComputerOption(0).Checked Then strComputer = ComputerOption(0).Value End If If ComputerOption(1).Checked Then strComputer = ComputerOption(1).Value End If If ComputerOption(2).Checked Then strComputer = ComputerOption(2).Value End If If ComputerOption(3).Checked Then strComputer = ComputerOption(3).Value End If
If strComputer = "" Then Exit Sub End If
Set objWMIService = GetObject _ ("winmgmts://" & strComputer & "/root/cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_Service") For Each objItem in ColItems strText = strText & objItem.Name & "<BR>" Next