use winrar command line to create zip archives

后端 未结 3 1627
余生分开走
余生分开走 2021-01-31 14:33

I\'m using the following winrar command line to create zip archives:

rar.exe a -df -ep -ag[yyyyMMddhhmmss] -ms[txt] C:\\MyZipFile.zip C:\\tmp\\MyFiles*.txt
         


        
3条回答
  •  别那么骄傲
    2021-01-31 15:34

    WinRAR has a detailed description of its command line syntax in its help files (WinRAR Help), chapter "Command line syntax".

    All the commands such as "a" (add to an archive), "d" (delete from an archive), "e" (extract from an archive ignoring paths) and switches such as "-af" (specify whether to create a rar or a zip file), "-ad" (append archive name to destination path) or "-p" (encrypt the archive using password protection) are listed there.

    There are quite a lot of options. I recommend reading the command line syntax rules when working with WinRAR via command lines.

    In order to trigger WinRAR zip-packaging from within a MS Access database application, I use in the VBA code for example

    Shell c:\Programme\WinRAR\winrar.exe a -afzip -p  "e:\MyStuff\TargetFolder\Output.zip" "e:\MyStuff\SourceFolder\Input.docx"
    

    Of course, the file paths and names are ususally entered via variables, e.g. like

    Dim strWinrarCommandline As String
    '... and the other variables as well declared in advance, of course...     
    
    strWinrarCommandline = strWinrarPathAndSwitches & "-p" & strPassword & " " & Chr(34) & strOutputFullName & Chr(34) & " " & Chr(34) & strInputFullName & Chr(34)
    

    'And then call Winrar simply by:

    Shell strWinrarCommandline
    

提交回复
热议问题