I am in need of an AutoIT script that will remove all printers an the unused printer drivers except for Adobe PDF.
I have a VBS script that does this, but it's a pain to always have to log out the user and log in as the administrator to accomplish this task.
I have tried converting the VBS script into AU3 scriping, but it didn't work.
below is the VBS Script I have. Any help would be appreciated.
Thanks in advance.
strComputer = "." intSleep = 3000 strService = " 'Spooler' " Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & strComputer & "\root\cimv2") Set colListOfServices = objWMIService.ExecQuery _ ("Select * from Win32_Service Where Name ="_ & strService & " ") For Each objService in colListOfServices objService.StopService() WSCript.Sleep intSleep Next Set WSHShell = WScript.CreateObject("WScript.Shell") strRegKey="HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\DefaultSpoolDirectory" DeleteFile WSHShell.RegRead(strRegKey) & "\*.SPL" DeleteFile WSHShell.RegRead(strRegKey) & "\*.SHD" Set colListOfServices = objWMIService.ExecQuery _ ("Select * from Win32_Service Where Name ="_ & strService & " ") For Each objService in colListOfServices objService.StartService() WSCript.Sleep intSleep Next function DeleteFile(WhatFile) on Error Resume Next set fso=createobject("Scripting.Filesystemobject") fso.DeleteFile(WhatFile) End Function on Error Resume Next Set objDictionary = CreateObject("Scripting.Dictionary") Set colPrinters = objWMIService.ExecQuery _ ("Select * from Win32_Printer") '***delete all Printers from the computer For Each objPrinter in colPrinters If Not objPrinter.Name="Adobe PDF" Then If Not objPrinter.Name="Acrobat Distiller" Then ObjPrinter.Delete_ End If End If Next '***delete the TCPIP-printer-ports For Each objPrinter in colPrinters objDictionary.Add objPrinter.PortName, objPrinter.PortName Next Set colPorts = objWMIService.ExecQuery _ ("Select * from Win32_TCPIPPrinterPort") For Each objPort in colPorts If objDictionary.Exists(objPort.Name) Then Else ObjPort.Delete_ End If Next '***un-install the printer drivers Set WSHShell = CreateObject("WScript.Shell") WSHShell.Run "Cscript.exe %windir%\system32\prndrvr.vbs -x -s %computername%", 0, False

Sign In
Register
Help
MultiQuote