Dim PrtSet, Prt, Locator, Service, MesStr, Fs, Txt File = "defaut_printer.txt" Set Locator = CreateObject("WbemScripting.SWbemLocator") Set Service = Locator.ConnectServer Set PrtSet = Service.ExecQuery("Select * From Win32_Printer") Set Fs = WScript.CreateObject("Scripting.FileSystemObject") If Fs.FileExists(File) Then Fs.DeleteFile File, True Set Txt = Fs.OpenTextFile(File, 2, True) For Each Prt In PrtSet '通常使うプリンターを取得 If Prt.Default Then Txt.WriteLine Prt.Caption MsgBox "通常使うプリンタ: " & Prt.Caption End If Next Txt.Close Set Txt = Nothing Set Fs = Nothing Set Prt = Nothing Set PrtSet = Nothing Set Service = Nothing Set Locator = Nothing