- WMI Fun !! -|WMI StepWMI SampleSearchWMI Fun !! GroupsAbout WMI Fun !!
Top Page >> WMI Step >> ページファイルの容量を設定する
ページファイルの容量を設定する
Topics

ページファイルの容量を設定するサンプルです。Win32_PageFileSettingクラスを使用しています。尚Cドライブにページファイルがあることを想定しています。


Sample Code

Private Sub Command1_Click()

Dim PgfSet As SWbemObjectSet
Dim Pgf As SWbemObject
Dim Locator As SWbemLocator
Dim Service As SWbemServices

Set Locator = New WbemScripting.SWbemLocator
Set Service = Locator.ConnectServer

Set PgfSet = Service.ExecQuery _
    ("Select * From Win32_PageFileSetting Where Name = 'C:\\pagefile.sys'")
For Each Pgf In PgfSet

    MsgBox "変更前の最大サイズ:" + CStr(Pgf.MaximumSize)

    Pgf.MaximumSize = Pgf.MaximumSize + 10
    Pgf.Put_

Next

Set PgfSet = Service.ExecQuery _
    ("Select * From Win32_PageFileSetting Where Name = 'C:\\pagefile.sys'")
For Each Pgf In PgfSet

    MsgBox "変更後の最大サイズ:" + CStr(Pgf.MaximumSize)

Next

Set PgfSet = Nothing
Set Pgf = Nothing
Set Locator = Nothing
Set Service = Nothing

End Sub

Comment

では実行してみましょう。
現在のページファイルの容量を取得した後にページファイルを10MB追加します。追加後のサイズを最後に表示しますのでそこでサイズが変わっていれば成功です。


WMI を本で勉強したい方へ。 Windows PowerShellインアクション を読んでみては?
なかなか WMI のことが乗っている書籍は少ないですが…管理系業務に係る方には楽しめるかも?
パソコンで目が疲れたら、ブルーベリーアイ
『ブルーベリーアイ』1粒中ビルベリーエキス160mg【楽天シニア市場】
 ^ Copyright(C) 1997-2008 とお All rights reserved. <<