rs79
rs79

Reputation: 2321

Writing to the same text file across different (shared) actions

I have a Master script which calls different actions (from different locations). I would like to write certain log messages during execution of this Master script. I have implemented a scripting object and a text file as

Set fso = CreateObject("Scripting.FileSystemObject")
Set  write_log =fso.CreateTextFile("C:\ExecutionLog.txt",true)
...
write_log.WriteLine("Execution Step 1 Completed)

Now, when a call is made to another (external) action, I am attempting to implement logging in the same file referenced above. I have tried the following, to no avail:

Set fso = CreateObject("Scripting.FileSystemObject")
Set write_log = fso.OpenTextFile("C:\ExecutionLog.txt", ForAppending, False)
...
write_log.WriteLine("Execution Step 10 Completed)

My question is how to write into the same file in different actions?

Upvotes: 1

Views: 520

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38745

If "to no avail" means "can't write to file in use by another process", you'll have to (Append)Open-Write-Close the file for each 'action' (script started by .Run or .Exec?) or even each single logging.

Upvotes: 1

Related Questions