Solved

Check if txt. file is in use in VBScript???

Posted on 2011-02-14
5
314 Views
Last Modified: 2012-05-11
I'm using "BarTender" (label generating software) that is referencing a .txt file on our network drive. Unique serial numbers are very important to us for tracking purposes after it leaves out factory. I have script that the BarTender label is opening the .txt file, reading the value, re-writing the new value (with the original value + the number of serial tags I want to print), saves, and then closes the .txt file. The problem I'm having is although a small window of time, if I hit print from two different work stations at the same instant, both work stations are opening the .txt file at the same time and allows duplicate printing to occur. What I'm hoping to find out is if there's a way to have the script check in the .txt file is open. If so, I want it to stop the job and return an error saying "file is use please try again". If it's not in use I'd like to to continue to run through my script of opening, reading, writing, saving and closing. Any help would be greatly appreciated. thank you!

-Mike Madsen
0
Comment
Question by:mmadsen32
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
Scottyworld earned 500 total points
ID: 34893227
Not sure if exactly what you want is possible (although an expert on here may prove me wrong!!)
A workaround would be when you open the file (eg: file1.txt) for editing the first thing your script could do would be to rename it to eg:file2.txt, make any changes, then rename it back to file1.txt when finished.
That way, if you run the same script on another workstation it will not be able to find the file (file1.txt) if it is in use
0
 

Author Comment

by:mmadsen32
ID: 34896584
Thanks Scott! I'll try it out and see if that fixes the problem. It seems like it should
0
 
LVL 9

Expert Comment

by:Scottyworld
ID: 35152028
Hi,
how did you get on? Did this help with the problem?
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 35465148
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question