Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

705 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

12 Experts available now in Live!

Get 1:1 Help Now