所以代码到目前为止有效,但是当我尝试使用函数找到的路径打开一个 txt 文件时,它不会打开 txt 文件。错误消息:对象不支持此属性或方法。
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Function GetFilePath(FileName)
Dim strScriptPath
strScriptPath = objFSO.GetFile(WScript.ScriptFullName).ParentFolder.ParentFolder.ParentFolder.Path
GetFilePath = (strScriptPath & "\" & FileName & ".txt")
wscript.echo GetFilePath
End Function
GetFilePath("ApprovedShares")
'Reads Approvedshare txt and makes the txt file into an array
Dim objApprovedFile, StrApprovedPath
StrApprovedPath = ("" & GetFilePath("ApprovedShares") & "")
wscript.echo StrApprovedPath
objApprovedFile = objFSO.OpenTextFile (StrApprovedPath)