Link to home
Start Free TrialLog in
Avatar of LBGUC04
LBGUC04

asked on

Uncompress File Through Cmd Shell

Hi all im using sql server 2000 and windows 2003 and i want to be able to uncompress a file using a cmd shell and wondered if anyone had the syntax to do this?
Avatar of EvilPostIt
EvilPostIt
Flag of United Kingdom of Great Britain and Northern Ireland image

When you say uncomress a file....

Do you mean the file has the compress attribue assigned to it?

Is the file compressed with a third party tool?

Is the file in a windows compressed folder?
Avatar of Bogeholm
Bogeholm

Try this VBScript:


http://www.robvanderwoude.com/vbstech_files_zip.php
Be sure to go to the "UNZIP with System.Shell Folder's CopyHere method", last on the page
Avatar of LBGUC04

ASKER

thank you for yoru response but this must be done using a sql statement
If you already have the command then just use

EXEC xp_cmdshell N'COMMAND'

Open in new window

Avatar of LBGUC04

ASKER

I have tried the following but i just get an error

exec master..xp_cmdshell 'Extract "U:\TestExtract\test.zip","U:\TestExtract"'


Extract - Verity, Inc. Version 5.0.0 (_nti40, May 13 2003)
Usage: extract [-xnv] -credentials user[:password][:domain][:mailbox] basename collname [query]
Hi LBGUC04

The internal command EXTRACT is not capable of extracting a ZIP-archieve!

You could use the VBScript i posted earlier. It can be executed using cscript.exe

E.g: "cscript.exe unzip.vbs"
Avatar of LBGUC04

ASKER

I need to find a way to do this using sql code, i can esily compress a file so there must be a way to unompress
Does the extract command that you ran inside of the xp_cmdshell work normally?
Avatar of LBGUC04

ASKER

i have never used it before i got it from the link above
Could you answer my original questions please?
Avatar of LBGUC04

ASKER

i did

Does the extract command that you ran inside of the xp_cmdshell work normally?

What does this mean?

If i run exec master..xp_cmdshell 'Extract'

then i get this

Extract - Verity, Inc. Version 5.0.0 (_nti40, May 13 2003)
Usage: extract [-xnv] -credentials user[:password][:domain][:mailbox] basename collname [query]

Sorry i waas refering to my first post.

When you say uncomress a file....

Do you mean the file has the compress attribue assigned to it?

Is the file compressed with a third party tool?

Is the file in a windows compressed folder?
ASKER CERTIFIED SOLUTION
Avatar of LBGUC04
LBGUC04

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi LBGUC04,

Please share your solution :-)
Avatar of LBGUC04

ASKER

--Uncompress Files
declare @sql varchar(8000)
set @sql = 'exec master..xp_cmdshell ''UNZIP -j -o U:\TestExtract\test.zip -d U:\TestExtract'''

print @sql
exec (@SQL)
Avatar of LBGUC04

ASKER

i have the answer