WshShell.Exec を使用して Windows のバージョンを取得する html アプリケーション (HTA) があります。wmic os get Caption
コマンドラインとバッチスクリプトで正常に動作する特定のバージョンを取得するために使用しています。呼び出し方法もテストしましたがWshShell.Exec
、他のコマンド (つまりecho Windows 2008
) で正常に動作します。Execがフリーズしているように見えるこれらのものを組み合わせようとすると、問題が発生します。これを回避する方法をお勧めできますか?これが私のコードです:
Function GetWinVersion
'Returns 2008, XP, or 7
set WshShell = CreateObject("WScript.Shell")
set oExec = WshShell.Exec("wmic os get Caption")
do while oExec.Status = 0
'I added this very busy wait, though it doesn't seem to help
'Would sleep if it was available in an hta
loop
While oExec.StdOut.AtEndOfStream <> True
thisLine = oExec.StdOut.ReadLine
'MsgBox "Found line: " & thisLine
if InStr(thisLine, "2008") > 0 then
GetWinVersion=2008
Exit Function
elseif InStr(thisLine, "XP") > 0 then
GetWinVersion=XP
Exit Function
elseif InStr(thisLine, "Windows 7") > 0 then
GetWinVersion=7
Exit Function
end if
Wend
MsgBox "Error parsing output of wmic os get Caption"
self.Close
End Function