• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3641
  • Last Modified:

Edit a .kix logon script

Hi,

I need to edit an existing .kix script that is use to map network printers and more.   I had to rename our printer server which is why I need to edit this script.  I can easily change the print sever name in the script but dont I also need to add to the script a command to remove to old mapped printers?  How do I do that?  Ive included the scipt below.  The print server needs to be change to ATLFPR06

SETTIME "\\atlfgg0001"

if exist( "c:\atlfg.txt" )
      USE i: /DEL
      DELKEY ("HKEY_CURRENT_USER\Network\I")      
      use i: "\\atlfgf0001\IT" /persistent
      GOTO FIN
ElSE
      GOTO MAP

:MAP

USE g: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\G")
USE h: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\H")
USE i: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\I")
USE l: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\L")
USE m: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\M")
USE n: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\N")
USE s: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\S")
USE t: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\T")
USE x: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\X")
USE w: /DEL
DELKEY ("HKEY_CURRENT_USER\Network\W")

use g: "\\atlfgf0001\Groups" /persistent
use h: "\\atlfgf0001\Apps" /persistent
use l: "\\atlfgf0001\F&C" /persistent
use s: "\\atlfgf0001\Shared" /persistent
use t: "\\atlfgf0001\Transfer" /persistent
use w: "\\atlfgf0001\White_Pages" /persistent

if (existkey ("HKEY_CURRENT_USER\Printers\Connections\,,atlfpr01,ATLFGP0001"))= 0
      GOTO MISC
ENDIF

DELTREE ("HKEY_CURRENT_USER\Printers\Connections")

If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0001") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0002") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0003") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0004") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0005") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0006") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0007") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0008") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0009") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0010") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0011") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0012") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0013") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0014") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0015") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0016") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0017") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0018") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0019") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0020") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0021") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0022") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0025") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0026") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0027") = 0
      ? "Added printer connection...."
If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0028") = 0
      ? "Added printer connection...."

:MISC
md "c:\windows\system32\ssaver"
copy \\atlfgf0001\cj\hosts C:\windows\system32\drivers\etc
copy \\atlfgf0001\cj\adcloc~1.url C:\docume~1\alluse~1\desktop
copy \\atlfgf0001\cj\window~1.lnk C:\docume~1\alluse~1\startm~1
copy \\atlfgf0001\cj\msnmes~1.lnk C:\docume~1\alluse~1\startm~1
copy \\atlfgf0001\cj\xp\bsa3.ico C:\windows
copy \\atlfgf0001\cj\xp\realye~1.url C:\docume~1\alluse~1\desktop
copy \\atlfgf0001\cj\xp\fitzco\ssaver.bmp C:\windows\system32\ssaver
del C:\docume~1\alluse~1\desktop\office~1.lnk
del c:\docume~1\alluse~1\startm~1\outloo~1.url
del c:\docume~1\alluse~1\desktop\outloo~1.url
del c:\docume~1\alluse~1\startm~1\setpro~1.lnk
del c:\docume~1\alluse~1\startm~1\window~1.lnk
del c:\docume~1\alluse~1\startm~1\tryaol~1.lnk
del c:\docume~1\alluse~1\desktop\msnexp~1.lnk
del c:\docume~1\alluse~1\desktop\freega~1.url
del c:\docume~1\alluse~1\startm~1\aolins~1.lnk
del c:\docume~1\alluse~1\startm~1\aimtri~1.lnk
if (existkey ("HKEY_CURRENT_USER\Printers\Connections\,,atlfpr01,ATLFGP0029"))= 0
      GOTO IT
ENDIF

If ADDPRINTERCONNECTION ("\\atlfpr01\atlfgp0029") = 0
      ? "Added printer connection...."
ENDIF

:IT
if ingroup("FGC ATL IT")
      USE i: /DEL
      DELKEY ("HKEY_CURRENT_USER\Network\I")      
      use i: "\\atlfgf0001\IT_Support" /persistent      
ELSE
      GOTO BIZ
ENDIF

:BIZ
if ingroup("FGC ATL NEW BUSINESS")
      use n: "\\atlfgf0001\New Business" /persistent      
ELSE
      GOTO LT
ENDIF

:LT
if exist( "c:\lt.txt" )
      copy \\atlfgf0001\cj\owa.url C:\docume~1\alluse~1\desktop
ELSE
      GOTO WSW
ENDIF

:WSW
if ingroup("FGC ATL WSW")
      copy \\atlfgf0001\cj\xp\wsw\ssaver.bmp C:\windows\system32\ssaver
ELSE
      GOTO REG
ENDIF

:REG
      $ReturnCode  =DelValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "TkBellExe")
      If $ReturnCode = 0      
      ? "Value deleted...."
endif      
      $ReturnCode  =DelValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "SunJavaUpdateSched")
      If $ReturnCode = 0      
      ? "Value deleted...."
endif      
      $ReturnCode  =DelValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "ViewMgr")
      If $ReturnCode = 0      
      ? "Value deleted...."
endif      
      $ReturnCode  =DelValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "NGClient")
      If $ReturnCode = 0      
      ? "Value deleted...."
endif      
      $ReturnCode  =DelValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "HostManager")
      If $ReturnCode = 0      
      ? "Value deleted...."
endif
      $WinXPIEPopUpBlockerKey=$hkcu+"\Software\Microsoft\Internet Explorer\New Windows"
      if ReadValue($WinXPIEPopUpBlockerKey,"PopupMgr")<>"no"
      if KeyExist($WinXPIEPopUpBlockerKey)=0
            $err=AddKey($WinXPIEPopUpBlockerKey)
      endif
      $err=WriteValue($WinXPIEPopUpBlockerKey,"PopupMgr","no","REG_SZ")
endif

:FIN
0
SBSailing
Asked:
SBSailing
1 Solution
 
RobSampsonCommented:
Hi, here's a VBS that will do what you are after, but I'm not that familiar with KIX and am not sure what the command is to remove a printer.....perhaps someone can convert this to KIX:
'====================
strComputer = "."

strOldServer = "\\OLDPRNSVR"
strNewServer = "\\NEWPRNSVR"
arrPrinterShares = Array("finance1", "finance2", "finance3")

Set objNetwork = CreateObject("WScript.Network")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colPrinters = objWMIService.ExecQuery _
    ("Select * From Win32_Printer Where Local = False")

If colPrinters.Count <> 0 Then
    For Each objPrinter In colPrinters
            For intPrinter = LBound(arrPrinterShares) To UBound(arrPrinterShares)
                  If UCase(objPrinter.DeviceID) = UCase(strOldServer & "\" & arrPrinterShares(intPrinter)) Then
                        If objPrinter.Default = True Then
                              objNetwork.RemovePrinterConnection objPrinter.DeviceID, True, True
                              objNetwork.AddWindowsPrinterConnection strNewServer & "\" & arrPrinterShares(intPrinter)
                              objNetwork.SetDefaultPrinter strNewServer & "\" & arrPrinterShares(intPrinter)
                        Else
                              objNetwork.RemovePrinterConnection objPrinter.DeviceID, True, True
                              objNetwork.AddWindowsPrinterConnection strNewServer & "\" & arrPrinterShares(intPrinter)
                        End If                              
                  End If
            Next
    Next
End If
'===============

Regards,

Rob.
0
 
SBSailingAuthor Commented:
Thanks for your help.

FYI - the comand kint to remove the printers using KIX is:
DELTREE ("HKEY_CURRENT_USER\Printers\Connections")
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now