Microsoft Active Server Pages (ASP) では、サーバー側スクリプトとクライアント側スクリプトの両方を含めることで、動的な Web ページを作成できます。 ASP ページは、ほとんどの作業がサーバーで行われるため、クライアント HTML ページよりもはるかに高速になる可能性があります。 ASP ページを使用して、Windows Management Instrumentation (WMI) がインストールされていない他のコンピューターにリモート コンピューターに関する情報を表示することもできます。
次の手順では、ASP で WMI を使用する方法について説明します。
ASP で WMI を使用するには
WMI を使用する ASP ページ (.asp) を作成し、Web サーバーからアクセスできるディレクトリに配置します。
匿名アクセスを無効にし、ASP ファイルの Windows 統合認証を有効にします。 ASP ページに対してこれらの設定を構成するには、コントロール パネルの 管理ツール フォルダーにある IIS スナップインを使用します。
WMI ASP ページの例
次の例では、Active Server ページ (ASP) 内の Windows Management Instrumentation (WMI) を使用して、このスクリプトの実行元サーバーの IP アドレスと既定の IP ゲートウェイ設定を表示します。
<%@ LANGUAGE="VBSCRIPT"%>
<HTML>
<HEAD>
<TITLE>WMI ASP Example:
Read Default Gateway and IP Address information </TITLE>
</HEAD>
<BODY>
<%
On Error Resume Next
set IPConfigSet = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!root\cimv2").ExecQuery" _
& "("SELECT IPAddress, DefaultIPGateway "" _
& " FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled=TRUE")
%>
<%If Err <> 0 Then %>
<%if err.number = -2147217405 then%>
<p>Error 0x80041003: Access Denied:
Check permissions and file security for this ASP file.</p>
<%else%>
<p>Error description: <%=Err.description%>
error number <%=Err.number%></p>
<%end if%>
<%end if %>
<%for each IPConfig in IPConfigSet%>
<%if Not IsNull(IPConfig.IPAddress) then %>
<%for i=LBound(IPConfig.IPAddress)
to UBound(IPConfig.IPAddress)%>
<p>IP Address: <%=IPConfig.IPAddress(i)%></p>
<%next%>
<%end if%>
<%if Not IsNull(IPConfig.DefaultIPGateway) then %>
<%for i=LBound(IPConfig.DefaultIPGateway)
to UBound(IPConfig.DefaultIPGateway)%>
<p>Default IP Gateway:
<%=IPConfig.DefaultIPGateway(i)%></p>
<%next%>
<%end if%>
<%next%>
<%If Err <> 0 Then %>
<p>error description: <%=Err.description%>
error number <%=Err.number%></p>
<%end if %>
</BODY>
</HTML>
このラーニング パスでは、Windows Management Instrumentation (WMI) と Common Information Model (CIM) について説明します。 これらのテクノロジは、コンピューターの情報にアクセスするのに役立ちます。 さらに、いずれのテクノロジも、ローカルおよびリモートのオペレーティング システム、コンピューター ハードウェア、インストールされているソフトウェアから管理情報にアクセスできます。