I'm trying to log certain information from my network of Windows machines; I've set them to periodically collect this info, then I want it in a single CSV file on a network drive. I'm using a VBS to collect this data, using OpenTextFile in append mode for writing. Will this allow multiple computers to simultaneously append a line to this file? Or is there another way to do this (apart from storing a separate file for each device).
I don't care about the order (I collect a timestamp from each device).
Windows has the ability to share concurrent access to files through mechanisms such as byte-range locks, whereby a process locks only a certain region of a file, etc. But applications have to be written appropriately to take advantage of this. It is entirely possible to code your application in such a way that you lock the entire file, and not just a region of it. You can even lock a file so that another process cannot even read from it.
However, you complicate things when you talk about accessing a file on a network file share. Now we're accessing files over the SMB network protocol.
SMB uses oplocks (opportunistic locks) and leases to manage concurrent access to files. The types of oplocks and leases are as follows:
Oplocks
Leases
Windows Internals 6th ed., Mark Russinovich, et al.
None of these modes are going to give you the shared write access you seek.
Change your strategy. Like MDMarra said, the Windows event log is a better choice. Another idea would be to have all the clients write to their own files in the file share, then have a server process collect all the files and aggregate them. You mention in your question that you're writing code, so you're in a position to change how this application works. I would suggest going to StackOverflow and asking them about the best way to approach shared write access to a single file over the network.
No. Once a file is opened for writing, it's locked. Other attempts to write while locked will result in "Access Denied."
You should consider writing whatever these events are to the local event logs and then use Event Log Subscriptions to pull all of these logs into a central source. From there, you can export it to whatever format you wish.
Another way of dealing with this problem might be to have each machine have an exclusive lock on the file while writing and releasing it immediately thereafter, and also have each machine programmed with a loop that tries to obtain write accessto the file, and, upon receiving an "access denied" message simply retries until the file is available. This person's need is to append short length log messages to the common file. Thus each machine would lock the file only briefly. A loop for obtaining an exclusive write lock would quickly obtain write access. Provided each process writes in append mode, I believe this should provide the needed function, whereby each machine adds to the log file as required.