| |
ehvbs
Posts: 2201
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
|
Hi JoshJarvis, assuming that the file should contain all local printers and that after the deinstallation of all local printers there should be no file with stale information hanging around: Const ForWriting = 2 Cinst csFSpec = "C:\LocalPrinters.txt" Set objFSO = CreateObject("Scripting.FileSystemObject") Set dicNames = CreateObject( "Scripting.Dictionary" ) strComputer = "." Set objNetwork = CreateObject("Wscript.Network") Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colPrinters = objWMIService.ExecQuery("Select * From Win32_Printer") For Each objPrinter in colPrinters If objPrinter.Attributes And 64 Then dicData( objPrinter.Name ) = "" End If Next If 0 < dicData.Count Then objFSO.CreateTextFile( csFSpec, True ) .Write Join( dicData.Keys, vbCrLf ) Else If objFSO.FileExists( csFSpec ) Then objFSO.DeleteFile csFSpec End If [Not tested] Please double check my and your usage of - and the Docs for - .CreateTextFile! Good luck! ehvbs
|
|