Avatar of amukta
amukta asked on

check to see if a file is locked

Hi!

How do we check to see if a .rar/.zip file is locked, using SSIS? If it is locked, then the package should stop executing. If the file is not locked, then it should unzip/extract/decompress the file using pkzip in the execute process task. How do we accomplish this using SSIS 2005. We should be using only PKZIP to decompress the file. What is the command that should be used to unzip/extract/decompress the file using pkzip.

Thanks  a million in advance.

Any logic/code is greatly appreciated. Can someone help me with this ASAP. I'm not permitted to install any additional zip/unzip software on the server.

I greatly appreciate your help ASAP.
Microsoft SQL ServerSSIS

Avatar of undefined
Last Comment
DcpKing

8/22/2022 - Mon
Anthony Perkins

For the record, this is a continuation of this thread:
https://www.experts-exchange.com/Microsoft/Development/Q_28215098.html
ASKER CERTIFIED SOLUTION
DcpKing

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
amukta

Thank you Mike,

I need to only unzip the files if they are not locked.if atleast one file is locked, my SSIS package should stop executing.i found some code online to check to see if the files are locked. But the file status of .rar/.zip is always always being shown as locked, even when they are not locked. Is there any special way of checking these files using a script task?
AlexPace

What if you did something that would fail if it is locked?

Like maybe use a script task to rename myfile.zip to myfile.ready.zip or move the file into another subfolder named ..\ready or something like that.

Maybe even use error handling and a loop.... if it fails, pause 30 seconds and try again... for up to a max of 10 retries....  that would be pretty cool.  You could make it send an email if it was still locked after the max number of retries.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
DcpKing

I think you may be looking in the wrong place if you're seeing the .zip files as always locked - or else the creation program hasn't finished with them yet.

You might try running the unzip on them from a batch file and seeing - if they unzip regardless then it really doesn't much matter whether you think that they're locked or not ...

Mike