Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-14
5
Medium Priority
?
320 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
Scottyworld earned 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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…

719 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