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)容呢?我們可以將該代碼分為四部分:其中有兩個部分使用 HTML 標記來實現(xiàn)單選按鈕以及“Run Script(運行腳本)”和“Cancel(取消)”按鈕,而另外兩個部分則根據(jù)您所點擊的是“Run Script”還是“Cancel”來運行子例程。讓我們更進一步了解這幾個部分。
例如,HTML 代碼在此顯示這四個單選按鈕。(如果您了解 HTML,那么這里就沒有什么特別的;這是標準的 HTML 編碼。)請注意,所有按鈕都有相同的名稱 (ComputerOption);這是為了確保一次只能選擇一個按鈕。還要注意,每個按鈕的“值”都被設為相應計算機的名稱:
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