G’day all.
I have an issue where i call to an agent using runonserver to create files on a netowork location. It uses
Set fsys = CreateObject(“scripting.filesystemobject”)
ane at the end of my code i use
set fsys = nothing
this hopefully kills the object so its not keeping any processes open on the server. Anyway, it only runs maybe 4 times before i start getting “Cannot create automation object” on the server and it wont write any more files. The files it creates looks just fine too. Any ideas on why it cant create the filesystemobject after a few sucessful gos?
Heres all my code
Server = "\myserver"
Share = “myshare”
TestName = “ElFileNameo”
Set fsys = CreateObject(“scripting.filesystemobject”)
Set outfile = fsys.createtextfile(Server & Share & "\Folder" & TestName & “.txt”)
Set outfile = Nothing
Set outfile = fsys.opentextfile(Server & Share & "\Folder" & TestName & “.txt”, 2)
outfile.writeline Format(Now, “m/d/yyyy”)
outfile.writeline Format(Now, “hh:mm”)
outfile.close
doc.HeaderFlag = 0
doc.Save True, False
Set doc = doccol.GetNextDocument(doc)
Set fsys = Nothing
Set outfile = Nothing
Exit Sub
errorhandler:
Set fsys = Nothing
Set outfile = Nothing
Exit Sub
Subject: Createobject only runs a few times
Have only used OLE with word and excel, however looking at the following two lines;Set outfile = fsys.createtextfile(Server & Share & "\Folder" & TestName & “.txt”)
Set outfile = Nothing
if the “createtextfile” creates the files and also opens it and assigns it to “outfile” variable then you should be calling a outfile.close before calling outfile=nothing because otherwise it will leave the actual file open on the machine and after a couple of attempts it probably runs out of file handles or something similar, hope it helps…
Subject: RE: Createobject only runs a few times
Thanks for the idea. I tried it, actually it ran about 10 times then started giving the infamous ‘connot create object’ error. Maybe domino is using that object for other purposes and not giving it up after the agent is done because of the other processes.
My other idea worked of writing a pure vb app that does all my network related file processes. Basically I write a file on the local C: of the server and then i use the external vb program (called by the agent) to process them out to the network. Its an overly complicated process but i have no other choice. Hopefully theyll fix it in the next rev or so.
Subject: Createobject only runs a few times
Setting fsys to nothing will only free the allocated memory. The problem may be that the application may still be running. Try quiting the scrippting application.
For example, I use following code for Excel without problem:
Set xlObj = CreateObject("Excel.Application")
Set xlApp = xlObj.Application
…
…
xlApp.Quit
Quit routine actually removes Excel.exe from OS’s process list.
HTH.
Subject: RE: Createobject only runs a few times
Well, I added an fsys.close at the end and still it stops being able to create a new scripting.filesystemobject after some sucessfull attempts. But it seems close in this instance is only for closeing a file stream.Microsoft Learn: Build skills that open doors in your career
Bunk
Anyway, any other ideas?
Subject: RE: Createobject only runs a few times
Well, after 4 days in the trash i decide bypass the problem (lotus notes) and use the
Open file For Output As #1
to write files to a directory and then call to another VB program to write the files to my places on the network. Anyway, thought id give my ‘gave up’ story so someone else doesnt have to waste thier time.
If programmer = “stressed” then
Language = “Lotusscript”
end if