Had some time and tried to convert this over to KiX.. Need to work on some details. Author's note: this has not been fully tested on systems with lpr ports, Adobe Acrobat, GhostScript, etc.

Code:

CLS
BREAK ON
; -- Step 1, Kill Citrix Connection Center
?'Killing Citrix Connection, if found'
ENDPROC('WFCRUN32.EXE') ; -- Would like to change this to where you log people out of Citrix
; -- Step 2, capture the network printers
PRINTCAPTURE(1)
; -- Step 3, do the work of removing all print drivers
?"Removes Windows printers (Registry-settings and printer driver's files)."
?'Remove all printers on '+@WKSTA
?'If you have RightFax Installed, you will need to re-configure the print driver'
?
SLEEP 2
$env='HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows NT x86\Drivers'
$fldr='%SystemRoot%\system32\spool\drivers\w32x86'
$print='HKLM\SYSTEM\CurrentControlSet\Control\Print'
$print1='HKLM\SYSTEM\CurrentControlSet001\Control\Print'

$cv='SOFTWARE\Microsoft\Windows NT\CurrentVersion'
SHELL '%COMSPEC% /C NET STOP SPOOLER'
$rc=DELTREE('HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers')
$rc=DELTREE('HKLM\SYSTEM\CurrentControlSet\Control\Print\Printers')
$rc=DELTREE($env+'\Version-2')
$rc=DELTREE($env+'\Version-3')
$rc=DELTREE('HKCU\Printers\Connections')
$rc=DELTREE('HKCU\'+$cv+'\PrinterPorts')
$rc=DELTREE('HKLM\'+$cv+'\Print\Providers\LanMan Print Services\Servers')
$rc=DELTREE($print1+'\Monitors\Standard TCP/IP Port\Ports')
$rc=DELTREE($print+'\Monitors\Standard TCP/IP Port\Ports')

$rc=WRITEVALUE($print+'\Printers','DefaultSpoolDirectory','%SystemRoot%\System32\spool\PRINTERS','REG_SZ')
$rc=WRITEVALUE($env+'\Version-2','Directory',2,'REG_SZ')
$rc=WRITEVALUE($env+'\Version-2','MajorVersion',2,'REG_DWORD')
$rc=WRITEVALUE($env+'\Version-2','MinorVersion',0,'REG_DWORD')

$rc=WRITEVALUE($env+'\Version-3','Directory',2,'REG_SZ')
$rc=WRITEVALUE($env+'\Version-3','MajorVersion',2,'REG_DWORD')
$rc=WRITEVALUE($env+'\Version-3','MinorVersion',0,'REG_DWORD')

$rc=ADDKEY('HKCU\Printers\Connections')
$rc=ADDKEY('HKCU\'+$cv+'\PrinterPorts')
$rc=ADDKEY('HKLM\'+$cv+'\Print\Providers\LanMan Print Services\Servers')
$rc=ADDKEY('HKLM\SYSTEM\ControlSet001\Control\Print\Monitors\Standard TCP/IP Port\Ports')
$rc=ADDKEY('HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\Standard TCP/IP Port\Ports')

$Dir = dirplus($fldr,"/s")
For Each $file In $dir
? $file
$Rc = SetFileAttr($file,128)
SHELL '%COMSPEC% /D Del '+$file
Next
SHELL '%COMSPEC% /C NET START SPOOLER'
; -- Step 4, Add the network printers back in
PRINTCAPTURE

?'Process is complete'
sleep 2

FUNCTION PRINTCAPTURE(OPTIONAL $capture)
DIM $loc,$reg,$dev,$nprt,$sysdrv,$priReg,$x,$i,$rc,$ps
$loc='HKCU\Network\LPT1'
$reg='HKCU\Software\Microsoft\Windows NT\CurrentVersion'
$dev=$reg+'\Devices'
$nprt=Split(ReadValue($reg+'\Windows','Device'),',')[0]
$sysdrv=SubStr('%WINDIR%',1,2)

$loc='HKCU\Network\LPT1'
$dev=$reg+'\Devices'
$nprt=Split(ReadValue($reg+'\Windows','Device'),',')[0]
If Exist('H:')
$ps='H:\Scripts_DO_NOT_DELETE'
Else
$ps=Left('%WINDIR%',2)+'\Scripts'
EndIf
If 0=Exist($ps)
MD $ps
EndIf
Select
Case
Ltrim(Split(@ipaddress0,'.')[0])+'.'+Ltrim(Split(@ipaddress0,'.')[1])='10.50'
$ps=$ps+'\PDX.ini'
Case
Ltrim(Split(@ipaddress0,'.')[0])+'.'+Ltrim(Split(@ipaddress0,'.')[1])='10.52'
$ps=$ps+'\GEMINI.ini'
Case
1
$ps=$ps+'\PRINTSETUP.ini'
EndSelect

IF $CAPTURE=1
$i=0
Do
If '\\'=Left($x,2)
$priReg=$priReg+$x
EndIf
$x=EnumValue($dev,$i)
$i=$i+1
Until @error

If Len($priReg)
$rc=WriteProfileString($ps,'Printers','','')
$priReg=Split($priReg,'\\')
For $i=1 to Ubound($priReg)
$rc=WriteProfileString($ps,'Printers',$i,'\\'+$priReg[$i])
Next
EndIf
ENDIF

Select
Case InStr($nprt,'\\') ;WRITE THE DEFAULT PRINTER TO THE CONFIG
$rc=WriteProfileString($ps,'Printers','Default',$nprt)
Use LPT1: /delete /persistent
Use LPT1: $nprt /persistent
Case Exist($ps) ;NO DEFAULT PRINTER, LOAD PRINTERS FROM SAVED INFO
For Each $key in Split(ReadProfileString($ps,'Printers',''),Chr(10))
$nul=AddPrinterConnection(ReadProfileString($ps,'Printers',$key))
Next
$nprt=ReadProfileString($ps,'Printers','Default')
$rc=SetDefaultPrinter($nprt)
Use LPT1: $nprt /persistent
Case Not InStr($nprt,'\\') ;LOCAL PRINTER DEFAULT, SO WE WANT TO REMOVE NETWORK MAPPING
Use LPT1: /delete /persistent
EndSelect
ENDFUNCTION

;NAME: ENDPROC
;AUTHOR: Kent Dyer (leptonator@hotmail.com)
;CONTRIBUTORS: Conrad Wheeler "Radimus", kholm
;ACTION: Terminates a local or remote process using WMI
;SYNTAX: ENDPROC($PROC,optional $COMPUTER)
;VERSION: 1.2
;PARAMETERS: $PROC
; Required string for the name of process you want to kill
; $COMPUTER
; Optional string containing the name of the system you are interested in,
; you could use @WKSTA
;RETURNS: Returncode (0) and PID
;REMARKS: Reference - Terminate all copies of the& nbsp;Notepad process on host TEST01
; Simplified (hopefully) version of kholm's script
; No warning about program being killed.
;DEPENDENCIES: Kixtart 4.0, WMI
;EXAMPLE(s): $COMPUTER = @WKSTA
; $PROC = "NOTEPAD.EXE"
;
; ENDPROC($PROC,$COMPUTER)
;
; Returns:
; 0
; notepad.exe is 1508
Function ENDPROC($PROC, optional $COMPUTER)
Dim $Process
If $COMPUTER=''
$COMPUTER='.'
EndIf
For Each $Process in GetObject('winmgmts:{impersonationLevel=impersonate}!\\'+$COMPUTER+'\root\cimv2')
.ExecQuery('Select * from Win32_Process where Name=' +'"'+$Proc+'"')
$Process.Terminate
?$Process.Name+' is '+$Process.ProcessId
Next
EndFunction

;Function DIRPlus()
;
;Author Bryce Lindsay bryce@isorg.net
;
;Action Returns an array containing directory files and folders
;
;Syntax DIRPLUS("PATH","OPTIONS")
;
;Version 2.0
;
;Date Posted Sep-11-2004
;
;Date Revised Dec-06-2004
;
;Revision reason Updated the required KiXtart version to 4.22 from 4.02 and some minor typos.
;
;Parameters Path
; Full path to a folder that you want to return information on.
; "c:\program files"
;
; OPTIONS
; /S Displays files In specified directory and all subdirectories.
;
; /A Displays files with specified attributes.
; attributes D Directories R Read-only files
; H Hidden files A Files ready for archiving
; S System files - Prefix meaning not
;
; /M Apply mask string to filter based on InSTR(), separate each search string with an |.
;
;
;Remarks Finally fixed this UDF to handle multiple recursions,
; also should have a faster response time since it is using the FSO
;
; ***Please note that the syntax for version 2.0 of this UDF has changed.***
;
; made some tweaks using feedback from Les! thanks!
;
;Returns Returns an array of FSO objects that are equal to the file and folder objects of
; the given path. Also returns an @ERROR code for event handling.
;
;Dependencies FSO
;
;KiXtart Ver 4.22
;
;Example(s) $Dir = dirplus("c:\program files") ;returns all files and folders in the "c:\program files" folder
; $Dir = dirplus("c:\program files","/s") ;all files and folders including subfolders
; $Dir = dirplus("c:\","/a-d") ;returns only a list of files In the c:\
; $Dir = dirplus("c:\","/ad") ;returns only a list of folders In the c:\
; $Dir = dirplus("c:\program files","/ad /s") ;returns only the folders including all subfolders.
;
; $Dir = dirplus("g:\kix\udf","/s /ad /m dir") ; recursive subfolder search, folders only, using a mask string of "dir"
;
; $desktop = dirplus("%userprofile%\desktop","/a-d")
; For Each $file In $desktop
; ? $file
; ? $file.size
; Next
;
;Source



Function DirPlus($path,optional $Options)
DIM $f, $file, $i, $temp, $item,$sfflag, $ex1, $mask,$maskArray,
$ex2, $code, $CodeWeight, $targetWeight, $weight, $masktrue
DIM $tarray[0]

$ex1 = SetOption(Explicit,on)
$ex2 = SetOption(NoVarsInStrings,on)
$codeWeight = 0

If Not Exist($path) Exit(2) EndIf
$f = CreateObject("Scripting.FileSystemObject").getfolder($path)
If @ERROR
$temp = SetOption(Explicit,$ex1)
$temp = SetOption(NoVarsInStrings,$ex2)
Exit @ERROR
EndIf

For Each $temp In Split($options,"/")
$temp=Trim($temp)
Select
Case $temp = "s"
$sfflag = 1
Case Left($temp,1) = "a"
Select
Case Right($temp,-1)="d"
$codeWeight = $codeWeight + 1
$temp = "if $file.type = 'File Folder' "
Case Right($temp,-1)="-d"
$codeWeight = $codeWeight + 1
$temp = "if $file.type <> 'File Folder' "
Case Right($temp,-1)="s"
$codeWeight = $codeWeight + 1
$temp = "if $file.attributes & 4 "
Case Right($temp,-1)="-s"
$codeWeight = $codeWeight + 1
$temp = "if ($file.attributes & 4)=0 "
Case Right($temp,-1)="h"
$codeWeight = $codeWeight + 1
$temp = "if $file.attributes & 2 "
Case Right($temp,-1)="-h"
$codeWeight = $codeWeight + 1
$temp = "if ($file.attributes & 2)=0 "
Case Right($temp,-1)="r"
$codeWeight = $codeWeight + 1
$temp = "if $file.attributes & 1 "
Case Right($temp,-1)="-r"
$codeWeight = $codeWeight + 1
$temp = "if ($file.attributes & 1)=0 "
Case Right($temp,-1)="a"
$codeWeight = $codeWeight + 1
$temp = "if $file.attributes & 32 "
Case Right($temp,-1)="-a"
$codeWeight = $codeWeight + 1
$temp = "if ($file.attributes & 32)=0 "
EndSelect
$code = $temp + "$weight=$weight+1 EndIf" +@CRLF + $code

Case Left($temp,1) = "m"
$maskarray = Split(Right($temp,-2),"|")
$codeweight = $codeweight + 1
$code = "$masktrue=0 for Each $mask in $maskarray if instr($file.name,$mask) $masktrue=1 " +
"EndIf Next If $masktrue $weight=$weight+1 EndIf" + @CRLF +$code
EndSelect
Next
$code = "$weight = 0 $targetWeight = " + $codeweight + @CRLF + $code
$code = $code + "if $weight = $targetweight Exit(1) EndIf"

For Each $file In $f.subfolders
If Execute($code)
$tarray[$i] = $file
$i = $i + 1
ReDIM PreServe $tarray[$i]
EndIf
If $sfflag
$temp = dirplus($file, $options)
For Each $item In $temp
$tarray[$i] = $item
$i = $i + 1
ReDIM PreServe $tarray[$i]
Next
EndIf
Next
For Each $file In $f.files
If Execute($code)
$tarray[$i] = $file
$i = $i + 1
ReDIM PreServe $tarray[$i]
EndIf
Next

If $i
ReDIM PreServe $tarray[$i-1]
$i=0
Else
$tarray = 0
EndIf

$dirplus = $tarray
$temp = SetOption(Explicit,$ex1)
$temp = SetOption(NoVarsInStrings,$ex2)
Exit @ERROR
EndFunction



Thanks,

Kent


Edited by kdyer (2005-09-24 06:34 AM)
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's