Solved

Kix script to Change unc paths in other Kix scripts

Posted on 2008-06-13
2
604 Views
Last Modified: 2008-07-11
I'm the new Windows 2003 Active Directory admin at my company. Right now we have about 300+ Windows XP workstations. They are stil using Kix scripts to map users to different network shares. Anyway, right now everyone's network account is setup with one of 15 different batch files that point to a specific kix script depending on their department or location / remote site. Anyway I'm going to be replace our file server at one of our remote sites and need to update users login scrript to use the new server name instead of the old one. How can I do this? Can a kix script be smart enough to use logic like if \\older-server exist change to \\New-Server??? Please help. Also how would I address users had have hard coded drive mapping to my older file server?
0
Comment
Question by:compdigit44
  • 2
2 Comments
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 21788340
Hi, I don't know much about Kix, but I see this problem being in two parts.

One is that you need to update your 15 or so Kix scripts to have their references to the old server point to the new file server.

Two is that you need to address any manual / custom mappings that a user might have.

For part one, I can provide a VBScript file that will change the references in your Kix scripts.  It will copy the files to a KIX_Backups folder in the source folder before changing them, but back them up yourself as well, just to be safe.

For part two, I will also provide a VBScript that can be used as a login script to remap a drive that might be mapped to the old server.

Regards,

Rob.
strScriptFolder = "\\server\netlogon"

strOldServer = "\\oldserver\share"

strNewServer = "\\newserver\share"

If Right(strScriptFolder, 1) = "\" Then strScriptFolder = Left(strScriptFolder, Len(strScriptFolder) - 1)

strBackupFolder = strScriptFolder & "\KIX_Backups"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Const intForReading = 1

If objFSO.FolderExists(strBackupFolder) = False Then objFSO.CreateFolder(strBackupFolder)

For Each objFile In objFSO.GetFolder(strScriptFolder).Files

	If Right(LCase(objFile.Name), 4) = LCase(".kix") Then

		strFilePath = objFile.Path

		objFSO.CopyFile strFilePath, strBackupFolder

		Set objKIXFile = objFSO.OpenTextFile(strFilePath, intForReading, False)

		strContents = objKIXFile.ReadAll

		objKIXFile.Close

		Set objKIXFile = Nothing

		strContents = Replace(LCase(strContents), LCase(strOldServer), LCase(strNewServer))

		Set objKIXFile = objFSO.CreateTextFile(strFilePath, True)

		objKIXFile.Write strContents

		objKIXFile.Close

		Set objKIXFile = Nothing		

	End If

Next

MsgBox "Done"

Open in new window

0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 500 total points
ID: 21788341
And here's part two.

Rob.
Set objNetwork = CreateObject("Wscript.Network")

strOldServer = "\\oldserver\share"

strNewServer = "\\newserver\share"

Set colDrives = objNetwork.EnumNetworkDrives

For i = 0 to colDrives.Count - 1 Step 2

	If Left(colDrives.Item(i + 1), Len(strOldServer)) = strOldServer Then

		strDriveLetter = colDrives.Item(i)

		objNetwork.RemoveNetworkDrive strDriveLetter, True, True

		If Len(colDrives.Item(i + 1)) > Len(strOldServer) Then

			objNetwork.MapNetworkDrive strDriveLetter, strNewServer & Mid(colDrives.Item(i + 1), Len(strOldServer) + 1), True

		Else

			objNetwork.MapNetworkDrive strDriveLetter, strNewServer, True

		End If

    End If

Next

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
split53 challenge 7 78
how to use wail2ban ?? 13 81
Running VB/Batch script through Group policy 30 79
ASP CDO - Limiting Connections 2 39
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now