Thanks for the response, I does not appear to be reading the file, I have added in the echo and got nothing back.
'====================
'
' Type: VBScript
'
' NAME: TSMFix.vbs
'
' AUTHOR: Bob Smith
'
' PURPOSE: This script will parse a list of servers, and modify the TSM
' config. It requires servers.txt in the same folder as this script.
' Servers.txt should contain one machine name per line.
'
' COMMENTS:
'
' **************************
' ~~~Begin Script~~~
Option Explicit
' Declare Everything!
Dim objFSO, objTextFile, objTextFile1, objTextFile2, objWMIService, objItem, objService, objChksrv, i
Dim strComputer, Line, strNextLine, Srvpad, colItems, colListOfServices, oDrives, WshNetwork
Dim drive, objShell
On Error Resume Next
Const ForReading = 1, ForWriting = 2
Set objFSO = CreateObject("Scripting.Fi
' Opens the servers.txt file to find the server name(s)
' --------------------------
Set objTextFile = objFSO.OpenTextFile("C:\Ts
Set WshNetwork = WScript.CreateObject("WScr
Set oDrives = WshNetwork.EnumNetworkDriv
Set objShell = WScript.CreateObject("WScr
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.Readline
'Check if the Server is online and has TSM folder
' --------------------------
Srvpad = "\\"&strComputer&"\c$\prog
IF objFSO.FolderExists(Srvpad
WScript.Echo "Server " & strServer & " doesn't have TSM or is offline!"
WScript.Quit
END If
' Backup current TSM config
objFSO.CopyFile Srvpad & "\dsm.opt" , Srvpad &"\dsm.opt.old"
' Wait for copy to complete
WScript.Sleep 10000
' Set TSM Service name
' --------------------------
Set objService = GetObject("WinMgmts:{imper
& strComputer & "/root/cimv2:Win32_Service
' Stop TSM Scheduler
' --------------------------
objService.StopService
' Set the file for Reading / Writing
' --------------------------
Set objTextFile2 = objFSO.OpenTextFile2(Srvpa
strText = objTextFile2.ReadAll
Wscript.Echo strText
objTextFile2.Close
strNewText = Replace(strText, "HYDRA1", "James")
Set objTextFile2 = objFSO.OpenTextFile(Srvpad
objTextFile2.WriteLine strNewText
objTextFile2.Close
' --------------------------
' Wait 10 seconds for things to settle down
WScript.Sleep 10000
' Start TSM Scheduler
objService.StartService
Wscript.Echo "The TSM Scheduler service on " & strComputer & " has restarted succesfully."
' Go get next computer name and start over...
Loop
objTextFile.Close
' --------------------------
' Functions
' --------------------------
'Read text file
Function GetFile(FileName)
If FileName<>"" Then
Dim FS, FileStream
Set FS = CreateObject("Scripting.Fi
on Error resume Next
Set FileStream = FS.OpenTextFile(FileName)
GetFile = FileStream.ReadAll
End If
End Function
'Write text file.
Function WriteFile(FileName, Contents)
Dim OutStream, FS
on Error Resume Next
Set FS = CreateObject("Scripting.Fi
Set OutStream = FS.OpenTextFile(FileName, 2, True)
OutStream.Write Contents
End Function
Main Topics
Browse All Topics





by: DarkoLordPosted on 2007-06-26 at 06:41:22ID: 19363517
Hi,
first make sure that the file gets read. Put an echo after you read the file to see if you get anything:
Wscript.Echo strText