• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1127
  • Last Modified:

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?
0
LBGUC04
Asked:
LBGUC04
  • 8
  • 5
  • 3
1 Solution
 
EvilPostItCommented:
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?
0
 
BogeholmCommented:
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
0
 
LBGUC04Author Commented:
thank you for yoru response but this must be done using a sql statement
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
EvilPostItCommented:
If you already have the command then just use

EXEC xp_cmdshell N'COMMAND'

Open in new window

0
 
LBGUC04Author Commented:
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]
0
 
BogeholmCommented:
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"
0
 
LBGUC04Author Commented:
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
0
 
EvilPostItCommented:
Does the extract command that you ran inside of the xp_cmdshell work normally?
0
 
LBGUC04Author Commented:
i have never used it before i got it from the link above
0
 
EvilPostItCommented:
Could you answer my original questions please?
0
 
LBGUC04Author Commented:
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]

0
 
EvilPostItCommented:
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?
0
 
LBGUC04Author Commented:
Dotn worry i founf out how to do it using UNZIP in cmd shell
0
 
BogeholmCommented:
Hi LBGUC04,

Please share your solution :-)
0
 
LBGUC04Author Commented:
--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)
0
 
LBGUC04Author Commented:
i have the answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now