This script reads a list of hostnames from a text file, checks for a file on the remote PC and depending on if it exists or not copies a file down to them. It works fine on the first hostname it reads in, then I get this error and the script stops running (the line in red is the line giving the error):
Script: test.vbs
Line: 6
Char: 1
Error: Object Variable not set
Code: 800A005B
Source: Microsoft VBScript runtime error
Const OverwriteExisting = True
Const ForReading = 1
Const ForAppending = 2
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objTextFile = objFSO.OpenTextFile ("c:\batch\list1.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
HostName = Split(strNextLine , ","
strHostName = HostName(0) & "\c$\Program Files\Lincare, Inc\O2Sales\O2SalesLive.mde"
strFileInUse = HostName(0) & "\c$\Program Files\Lincare, Inc\O2Sales\O2SalesLive.ldb"
If objFSO.FileExists(strFileInUse) Then
Set objTextFile = objFSO.OpenTextFile ("\\********\common\it_department\O2 Sales\ForcedUpdates\ForcedUpdate.txt", ForAppending, True)
objTextFile.WriteLine("File NOT Updated on " & HostName(0) & " at " & Time & " on " & Date)
objTextFile.Close
MsgBox "File has NOT been Updated on " & HostName(0),vbokonly,"Not Copied"
Else
objFSO.CopyFile "\\********\accessdb\o2sales\database\O2SalesLive.mde" , strHostName, OverwriteExisting
Set objTextFile = objFSO.OpenTextFile ("\\********\common\it_department\O2 Sales\ForcedUpdates\ForcedUpdate.txt", ForAppending, True)
objTextFile.WriteLine("File UPDATED on " & HostName(0) & " at " & Time & " on " & Date)
objTextFile.Close
MsgBox "File HAS been Updated on " & HostName(0),vbokonly,"Copied"
End If
Loop
I'm using Primalscript to write this if that makes a difference. Thanks in advance for any help on this.
Script: test.vbs
Line: 6
Char: 1
Error: Object Variable not set
Code: 800A005B
Source: Microsoft VBScript runtime error
Const OverwriteExisting = True
Const ForReading = 1
Const ForAppending = 2
Set objFSO = CreateObject("Scripting.FileSystemObject"
Set objTextFile = objFSO.OpenTextFile ("c:\batch\list1.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
HostName = Split(strNextLine , ","
strHostName = HostName(0) & "\c$\Program Files\Lincare, Inc\O2Sales\O2SalesLive.mde"
strFileInUse = HostName(0) & "\c$\Program Files\Lincare, Inc\O2Sales\O2SalesLive.ldb"
If objFSO.FileExists(strFileInUse) Then
Set objTextFile = objFSO.OpenTextFile ("\\********\common\it_department\O2 Sales\ForcedUpdates\ForcedUpdate.txt", ForAppending, True)
objTextFile.WriteLine("File NOT Updated on " & HostName(0) & " at " & Time & " on " & Date)
objTextFile.Close
MsgBox "File has NOT been Updated on " & HostName(0),vbokonly,"Not Copied"
Else
objFSO.CopyFile "\\********\accessdb\o2sales\database\O2SalesLive.mde" , strHostName, OverwriteExisting
Set objTextFile = objFSO.OpenTextFile ("\\********\common\it_department\O2 Sales\ForcedUpdates\ForcedUpdate.txt", ForAppending, True)
objTextFile.WriteLine("File UPDATED on " & HostName(0) & " at " & Time & " on " & Date)
objTextFile.Close
MsgBox "File HAS been Updated on " & HostName(0),vbokonly,"Copied"
End If
Loop
I'm using Primalscript to write this if that makes a difference. Thanks in advance for any help on this.