Solved

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

Posted on 2011-02-14
5
313 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now