Vbs Script To Create and Copy CCR’s Based On A Machine List

This Vbs script will take a list of machine names from a text file called MachineList.txt and create CCR files for each of them using the minimum information required to successfully create an NT client configuration request.

 

It will then copy the CCR files to the specified Site server and then delete the original files from the directory in which the script is executed from.

 

Note: Change all occurrences of C:\Temp\ to the directory in which the script is executed from.

 

Vbs Script

 

InputFile = "MachineList.Txt"

 

strSiteServer = InputBox("Enter Site Server Name")

strSiteCode = InputBox("Enter Site Code")

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(InputFile)

 

Do While Not (objFile.AtEndOfStream)

MachineName = objFile.ReadLine

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set Output = objFSO.CreateTextFile(MachineName & ".Ccr", True)

 

'Create CCR Files

Output.WriteLine("[NT Client Configuration Request]")

Output.WriteLine("   Client Type=1")

Output.WriteLine("   Forced CCR=TRUE")

Output.WriteLine("   Machine Name=" & MachineName)

Output.Close

Loop

 

'Copy CCR Files

On Error Resume Next

Const OverwriteExisting = True

Set objFSO = CreateObject("Scripting.FileSystemObject")

 

objFSO.CopyFile "C:\Temp\*.ccr" , "\\" & strSiteServer & "\SMS_" & strSiteCode & "\Inboxes\Ccr.Box\", OverwriteExisting

If Err.Number <> 0 Then           

Wscript.Echo "Error: " & Err.Number & " " & Err.Description

Wscript.Quit Err.Number

Else

 

'Delete CCR Files

objFSO.DeleteFile("C:\Temp\*.ccr")

End If

 

Wscript.Echo "Done"

 

Published Sunday, September 10, 2006 12:31 PM by dhite
Filed under:

Comments

# VBS Script To Create A CCR For A Specified Advanced Client Machine

This VBS script will allow you to enter an Advanced client resource machine name into an input dialog

Sunday, May 11, 2008 9:03 AM by Don Hite