Reputation: 134
So I have read all kinds of answers to this question and I have implemented them to the best of my understanding. Even after defining constants and checking to ensure that my target file exists, I am still receiving this error. It certainly has to do with the passing of the optional parameters for OpenTextFile - the code will run if I pass only the file path and name. Because the target file is in Unicode, however, this does not work for my uses. More importantly, I would like to understand what is happening here after spending more than a few hours trying to decipher this issue. I greatly appreciate any help offered. Thank you.
For Reference, the error I am receiving is:
Unhandled exception at line 17, column 3 in GetNewVersion.vbs
0x800a0005 - Microsoft VBScript runtime error: Invalid procedure call or argument
Option Explicit
const ForReading = 1
const TristateTrue = 1
Dim strComputer, objWMIService, fso, ts, objShell, sTempDir, sPID, sFilePath, sFileName, colProcessList, objProcess,listInfo, lineInfo
'Create File System Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Locate Temp Directory
sTempDir = fso.GetSpecialFolder(2)
sTempDir = sTempDir & "\DBUpdateInfo.txt"
'Ensure DBUpdateInfo.txt exists
If fso.FileExists(sTempDir) Then
Set ts = fso.OpenTextFile(sTempDir,ForReading,False,TristateTrue)
...
Upvotes: 1
Views: 1277