Why does this have a windows-server-powershell tag?
Probably because the Powershell tag will be seen by folks who tend to answer scripting questions. Like you and me.
The script stops when executing the following line: executeglobal fso.opentextfile("C:\Scripts\MyFile.txt", 1).readall
I think that the best course of action would be to build a test script that recreates the error. That way forum users who have access to 2019 server can run it to verify that there is a bug in the OS.
Given that MS is no longer enhancing VB script, I would be surprised if there was a change in 2019 that broke your script. I would suspect something else in the script or something in your environment (antivirus?) that might be the root problem.
Willy, do you have a test script, or can you build a generic one based on however your script uses function's, sub's, and whatever?
I threw this together just to play with. It works on Win10, but I don't have a 2019 server to test on.
option explicit
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim oFs, oF
Dim strData
Dim somefile
somefile = "C:\temp\tst.txt" ' <<<===== put a file name here
wscript.echo "Script host version " & ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion
Foo
Foo2
wscript.echo "Done."
function Foo()
Set ofs = CreateObject("Scripting.FileSystemObject")
strData = oFs.opentextFile(somefile,ForReading).readall
wscript.echo len(strData)
strData = ""
executeglobal "strData = oFs.opentextFile(somefile,ForReading).readall"
wscript.echo len(strData)
strData = ""
execute "strData = oFs.opentextFile(somefile,ForReading).readall"
wscript.echo len(strData)
end function
Sub Foo2()
Set ofs = CreateObject("Scripting.FileSystemObject")
strData = oFs.opentextFile(somefile,ForReading).readall
wscript.echo len(strData)
strData = ""
executeglobal "strData = oFs.opentextFile(somefile,ForReading).readall"
wscript.echo len(strData)
strData = ""
execute "strData = oFs.opentextFile(somefile,ForReading).readall"
wscript.echo len(strData)
end sub