Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to extract zip file using inbuilt Dos command of Windows XP  (Read 90784 times)

0 Members and 1 Guest are viewing this topic.

NehalShah

    Topic Starter


    Starter

    How to extract zip file using inbuilt Dos command of Windows XP
    « on: September 18, 2008, 10:58:27 PM »
    Hi,

    I would like to have dos command to extract zip files.
    Note: i cannot use third party software like winzip and winrar.

    For OS above XP 'compressed (zipped) folder' facility is available, where you right click folder and click 'send to' ->  ''compressed (zipped) folder', a zip file will be created within that folder.
    Now select this zip file and right click, 'extract all' menu will be available.
    If you select this, wizard will open to extract file.
    I want this through Dos Prompt so that i can use it in my batch file.

    Thanks

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: How to extract zip file using inbuilt Dos command of Windows XP
    « Reply #1 on: September 19, 2008, 03:21:55 AM »
    I'm not aware you can do this at the prompt without a third party program. You can however create a your own command and have it run from the prompt or a batch file.

    Unzip
    Code: [Select]
        strZipFile = ""                                       'name of zip file
        outFolder = ""                                       'destination folder of unzipped files
       
        Set objShell = CreateObject( "Shell.Application" )
        Set objSource = objShell.NameSpace(strZipFile).Items()
        Set objTarget = objShell.NameSpace(outFolder)
        intOptions = 256
        objTarget.CopyHere objSource, intOptions

    Fill in the appropriate names for the zip file and the output folder (must be quoted). Save the script with a vbs extension. In your batch file you can run the script with this entry: cscript //nologo scriptname.vbs

    Good luck.  8)

    Note: option 256 displays a progress dialog box but does not show the file names.
    « Last Edit: September 19, 2008, 03:32:15 AM by Sidewinder »
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    nameless_man

    • Guest
    Re: How to extract zip file using inbuilt Dos command of Windows XP
    « Reply #2 on: October 13, 2008, 08:53:56 AM »
    Thanks for the info! Hopefully you can help me with an issue on this...

    In a folder I have the following 3 files:

    test.zip
    unz.bat
    unz.vbs

    When I run  unz.bat  in a command window, the following message displays:

    unz.vbs(5, 1) (null): The system cannot find the file specified.

    When a friend runs my same files on his XP machine, it runs fine. Is there a system file I am missing?

    This is the contents of my files:

    file: unz.bat
    --------------------------------

    cscript //nologo unz.vbs


    file: unz.vbs
    --------------------------------

    strZipFile = "c:\DONZ\test.zip"         
    outFolder = "c:\DONZ\"
       
    Set objShell = CreateObject( "Shell.Application" )
    Set objSource = objShell.NameSpace(strZipFile).Items()
    Set objTarget = objShell.NameSpace(outFolder)
    intOptions = 256
    objTarget.CopyHere objSource, intOptions

    Thank you for any help!

    killerb255



      Adviser
    • Thanked: 35
      • Experience: Expert
      • OS: Windows 7
      Re: How to extract zip file using inbuilt Dos command of Windows XP
      « Reply #3 on: October 13, 2008, 12:38:11 PM »
      Does the folder containing those files have a long file name or a name with spaces?

      You may have to put the entire path name after cscript //nologo.

      For example, if you have those files in C:\Unzipping Path, you'll have to use this:

      cscript //nologo "C:\Unzipping Path\unz.vbs"
      Quote from: talontromper
      Part of the problem is most people don't generally deal with computer problems. So for most they think that close enough is good enough.

      zachdoesit



        Newbie

        Re: How to extract zip file using inbuilt Dos command of Windows XP
        « Reply #4 on: October 24, 2008, 01:21:43 PM »
        I used the same script and get the following error:

        Quote
        Microsoft VBScript runtime error: Object required: 'objShell.NameSpace(...)'

        Here is my code:
        Code: [Select]
        strZipFile = "c:\documents and settings\%username%\fr5\resource.zip"
        outFolder = "c:\documents and settings\%username%\fr5\"
           
        Set objShell = CreateObject( "Shell.Application" )
        Set objSource = objShell.NameSpace(strZipFile).Items()
        Set objTarget = objShell.NameSpace(outFolder)
        intOptions = 256
        objTarget.CopyHere objSource, intOptions

        I've checked, retyped the code, copied the code, etc. What am I missing?

        Sidewinder



          Guru

          Thanked: 139
        • Experience: Familiar
        • OS: Windows 10
        Re: How to extract zip file using inbuilt Dos command of Windows XP
        « Reply #5 on: October 24, 2008, 01:41:52 PM »
        Quote
        I used the same script and get the following error:

        The same script would have worked!  ;)

        In this context, the username variable needs to be expanded:

        Code: [Select]
        Set WshShell = CreateObject("Wscript.Shell")
        user = WshShell.ExpandEnvironmentStrings("%UserName%")

        strZipFile = "c:\documents and settings\" & user & "\fr5\resource.zip"
        outFolder = "c:\documents and settings\" & user & "\fr5\"
           
        Set objShell = CreateObject( "Shell.Application" )
        Set objSource = objShell.NameSpace(strZipFile).Items()
        Set objTarget = objShell.NameSpace(outFolder)
        intOptions = 256
        objTarget.CopyHere objSource, intOptions

        Everything else being equal, this should work.  8)
        The true sign of intelligence is not knowledge but imagination.

        -- Albert Einstein

        zachdoesit



          Newbie

          Re: How to extract zip file using inbuilt Dos command of Windows XP
          « Reply #6 on: October 24, 2008, 04:30:05 PM »
          Thanks, Sidewinder. Worked like a charm.  8)

          Boer86

          • Guest
          Re: How to extract zip file using inbuilt Dos command of Windows XP
          « Reply #7 on: January 21, 2009, 12:15:56 AM »
          Hey guys. I hope someone is still looking at this thread as I require some help and quite urgently. The unzip seems to be working fine but the files I receive is always named differently because they contain a date and they are password encrepted. How can I specify the password in the script and also tell it to extract all files inside a certain directory not just one? Thanks in advance

          Sidewinder



            Guru

            Thanked: 139
          • Experience: Familiar
          • OS: Windows 10
          Re: How to extract zip file using inbuilt Dos command of Windows XP
          « Reply #8 on: January 21, 2009, 05:54:04 AM »
          Quote
          Hey guys. I hope someone is still looking at this thread as I require some help and quite urgently

          This would be reason number one why you should start your own thread. Many people will see this thread with 7 replies and deduce that there is nothing more to add. Reason number two is that it is considered rude to hijack someone else's thread, no matter how old.

          Quote
          The unzip seems to be working fine but the files I receive is always named differently because they contain a date and they are password encrepted.

          Use the same algorithm as the sender to determine the received file name. You might also determine what files are in the receive directory, and sequentially unzip each one.

          Did you use some 3rd party program to compress your files? Windows compressed files don't have a password option and they cannot be encrypted.

          Need more info.  8)
          « Last Edit: January 21, 2009, 09:20:20 AM by Sidewinder »
          The true sign of intelligence is not knowledge but imagination.

          -- Albert Einstein

          Helpmeh



            Guru

          • Roar.
          • Thanked: 123
            • Yes
            • Yes
          • Computer: Specs
          • Experience: Familiar
          • OS: Windows 8
          Re: How to extract zip file using inbuilt Dos command of Windows XP
          « Reply #9 on: January 21, 2009, 02:55:08 PM »
          .ZIP folders have the option of having a password to prevent the extraction of the files...also prevents WinRAR from extracting as well.
          Where's MagicSpeed?
          Quote from: 'matt'
          He's playing a game called IRL. Great graphics, *censored* gameplay.

          Ajay



            Starter

            Re: How to extract zip file using inbuilt Dos command of Windows XP
            « Reply #10 on: May 28, 2009, 04:37:35 AM »
            Hi All,

            I am getting the Error while I am trying to run the Script


            Test.VBS(5, 1) Microsoft VBScript runtime error: Object required:
             'objShell.NameSpace(...)'


            ndate = date()
            ndate = ndate-0
            strlongdate = formatdatetime(ndate,vblongdate)
            strshortdate = formatdatetime(ndate,vbshortdate)
            'wsh.echo "The yesterday date is : " & cstr(ndate)
            'wsh.echo "The long date : " & strlongdate
            'wsh.echo "The short date : " & strshortdate
            strshortdatearray = split(strshortdate,"/")
            'wsh.echo cstr(strshortdatearray(0))
            'wsh.echo cstr(strshortdatearray(1))
            'wsh.echo cstr(strshortdatearray(2))


            '**********Set these values accordingly to the date format of the machine (2008-01-01)***********

            str_short_year = cstr(strshortdatearray(2))
            str_short_month =  cstr(strshortdatearray(1))
            str_short_day =  cstr(strshortdatearray(0))

            if len(str_short_day ) = 1 then
               
               str_short_day  = "0" & str_short_day

            end if

            if len(str_short_month  ) = 1 then
               
               str_short_month  = "0" & str_short_month 
            end if

            Option Explicit
            'Extract "E:\PrePaid_Data\TN\SFAF\08_BAN_TN_SFAF_" &  str_short_year & str_short_day  & str_short_month & ".zip", "E:\PrePaid_Data\TN\SFAF\"

            Extract "E:\PrePaid_Data\TN\01_BAN_TN_ADJM_20090528.txt.zip", "E:\PrePaid_Data\TN"

            Sub Extract( ByVal myZipFile, ByVal myTargetDir )
                Dim intOptions, objShell, objSource, objTarget
                Set objShell = CreateObject( "Shell.Application" )
                Set objSource = objShell.NameSpace( myZipFile ).Items( )
                Set objTarget = objShell.NameSpace( myTargetDir )
                Set colItems = objFolder.Items
                intOptions = 256
                objTarget.CopyHere objSource, intOptions
                Set objSource = Nothing
                Set objTarget = Nothing
                Set objShell  = Nothing
            End Sub

            ndate = date()
            ndate = ndate-0
            strlongdate = formatdatetime(ndate,vblongdate)
            strshortdate = formatdatetime(ndate,vbshortdate)
            'wsh.echo "The yesterday date is : " & cstr(ndate)
            'wsh.echo "The long date : " & strlongdate
            'wsh.echo "The short date : " & strshortdate
            strshortdatearray = split(strshortdate,"/")
            'wsh.echo cstr(strshortdatearray(0))
            'wsh.echo cstr(strshortdatearray(1))
            'wsh.echo cstr(strshortdatearray(2))


            '**********Set these values accordingly to the date format of the machine (2008-01-01)***********

            str_short_year = cstr(strshortdatearray(2))
            str_short_month =  cstr(strshortdatearray(1))
            str_short_day =  cstr(strshortdatearray(0))

            if len(str_short_day ) = 1 then
               
               str_short_day  = "0" & str_short_day

            end if

            if len(str_short_month  ) = 1 then
               
               str_short_month  = "0" & str_short_month 
            end if

            Option Explicit
            'Extract "E:\PrePaid_Data\TN\SFAF\08_BAN_TN_SFAF_" &  str_short_year & str_short_day  & str_short_month & ".zip", "E:\PrePaid_Data\TN\SFAF\"

            Extract "E:\PrePaid_Data\TN\01_BAN_TN_ADJM_20090528.txt.zip", "E:\PrePaid_Data\TN"

            Sub Extract( ByVal myZipFile, ByVal myTargetDir )
                Dim intOptions, objShell, objSource, objTarget
                Set objShell = CreateObject( "Shell.Application" )
                Set objSource = objShell.NameSpace( myZipFile ).Items( )
                Set objTarget = objShell.NameSpace( myTargetDir )
                Set colItems = objFolder.Items
                intOptions = 256
                objTarget.CopyHere objSource, intOptions
                Set objSource = Nothing
                Set objTarget = Nothing
                Set objShell  = Nothing
            End Sub



            ndate = date()
            ndate = ndate-0
            strlongdate = formatdatetime(ndate,vblongdate)
            strshortdate = formatdatetime(ndate,vbshortdate)
            'wsh.echo "The yesterday date is : " & cstr(ndate)
            'wsh.echo "The long date : " & strlongdate
            'wsh.echo "The short date : " & strshortdate
            strshortdatearray = split(strshortdate,"/")
            'wsh.echo cstr(strshortdatearray(0))
            'wsh.echo cstr(strshortdatearray(1))
            'wsh.echo cstr(strshortdatearray(2))


            '**********Set these values accordingly to the date format of the machine (2008-01-01)***********

            str_short_year = cstr(strshortdatearray(2))
            str_short_month =  cstr(strshortdatearray(1))
            str_short_day =  cstr(strshortdatearray(0))

            if len(str_short_day ) = 1 then
               
               str_short_day  = "0" & str_short_day

            end if

            if len(str_short_month  ) = 1 then
               
               str_short_month  = "0" & str_short_month 
            end if

            Option Explicit
            'Extract "E:\PrePaid_Data\TN\SFAF\08_BAN_TN_SFAF_" &  str_short_year & str_short_day  & str_short_month & ".zip", "E:\PrePaid_Data\TN\SFAF\"

            Extract "E:\PrePaid_Data\TN\01_BAN_TN_ADJM_20090528.txt.zip", "E:\PrePaid_Data\TN"

            Sub Extract( ByVal myZipFile, ByVal myTargetDir )
                Dim intOptions, objShell, objSource, objTarget
                Set objShell = CreateObject( "Shell.Application" )
                Set objSource = objShell.NameSpace( myZipFile ).Items( )
                Set objTarget = objShell.NameSpace( myTargetDir )
                Set colItems = objFolder.Items
                intOptions = 256
                objTarget.CopyHere objSource, intOptions
                Set objSource = Nothing
                Set objTarget = Nothing
                Set objShell  = Nothing
            End Sub




            Resolve Any ONE              ASAP............................