VB调用WINRAR解压文件到当前文件夹,自动覆盖已存在文件帮我写句代码

解决方案 »

  1.   

    用shell
      

  2.   

    Set wsh = CreateObject("wscript.shell")
    WinRAR = wsh.regread("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WinRAR.exe\")
    If WinRAR = "" Then MsgBox "系统内未安装 WinRAR 程序。": Exit Sub
    sfile = "C:\test.rar"
    If Dir(sfile) = "" Then MsgBox "找不到压缩文件。": Exit Sub
    Shell WinRAR & " e -y """ & sfile & """", vbHide
      

  3.   

    如果随程序自带rar.exe 则无需判断winrar位置 直接shell 即可:Shell "rar.exe e -y """ & sfile & """", vbHide