JohnRichard 0 Posted April 25, 2011 good day to all. i am trying to make a script which will delete Microsoft Office Document Image Writer and Microsoft XPS Document Writer printer installed to all PC's in our network. i will initiate a registry delete of the entry of the printers. my test script works fine on the first registry part but the second case, it will fail to delete. can someone help me why the script don't work as what i need to. thanks... below is my script For $i= 1 to 10 $var = RegEnumKey("\\12.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers", $i) If @error <> 0 then ExitLoop ;MsgBox(4096, "SubKey #" & $i & " under HKLM\Software: ", $var) Select Case $var = "Microsoft Office Document Image Writer" ;$read = RegRead("\\10.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft Office Document Image Writer", "Name") RegDelete("\\12.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft Office Document Image Writer") Case $var = "Microsoft XPS Document Writer" ; $read = RegRead("\\10.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft XPS Document Writer", "Name") RegDelete("\\12.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft XPS Document Writer") EndSelect Next ShellExecute("sc.exe", "\\12.110.1.12 stop SPOOLER", @SystemDir) ShellExecute("sc.exe", "\\12.110.1.12 start SPOOLER", @SystemDir) Share this post Link to post Share on other sites
JohnOne 1,603 Posted April 25, 2011 You could start by helping yourself a little. Take a look at the Regdelete() function in the helpfile, and its return values and @error values, and add a little error checking. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
JohnRichard 0 Posted April 25, 2011 You could start by helping yourself a little. Take a look at the Regdelete() function in the helpfile, and its return values and @error values, and add a little error checking. Hi JohnOne, I've done that. This line of script will list if PC has Microsoft Document Writer and Microsoft XPS installed in PC.... $var = RegEnumKey("\\10.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers", $i) Then on the Select Case, If the script match the registry name of the printer, it will delete the value... The first select case works fine... Select Case $var = "Microsoft Office Document Image Writer" ;$read = RegRead("\\10.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft Office Document Image Writer", "Name") RegDelete("\\12.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft Office Document Image Writer") but the second select case, it failed to delete Case $var = "Microsoft XPS Document Writer" RegDelete("\\12.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft XPS Document Writer") I wonder why the second case is not being executed.... Share this post Link to post Share on other sites
JohnOne 1,603 Posted April 25, 2011 This is why you must add some error checking, to indicate to you whay it is failing. RegDelete("\\12.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft XPS Document Writer") ConsoleWrite("RegDelete @error " & @error & @CRLF) AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
JohnRichard 0 Posted April 25, 2011 This is why you must add some error checking, to indicate to you whay it is failing.RegDelete("\\12.110.1.12\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\Microsoft XPS Document Writer")ConsoleWrite("RegDelete @error " & @error & @CRLF)Hi JohnOne. I managed to make it working without this error checking you advise. Thanks anyway... Cheers... Share this post Link to post Share on other sites
JohnOne 1,603 Posted April 25, 2011 Thats great, but its still I good Idea to have it, and will save you stress in the future. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites