nodejs调用WinRAR解压

荒凉一梦 提交于 2020-02-09 01:40:18
var cp = require("child_process");

function unZIP(winRarPath, password, zipFilePath, unZipFolder) {
    return new Promise(async (resolve, reject) => {
        cp.execFile(winRarPath, ["x", "-inul", `-p${password}`, zipFilePath, unZipFolder], function (err, stdout, stderr) {
            if (err) {
                reject(err)
            }
            resolve(stdout)
        })
    })
}
async function main(){
    try {
        let result = await unZIP("C:\\Program Files\\WinRAR\\WinRAR.exe", '111111', "D:\\test\\新建文本文档.rar", "D:\\test");
        console.log('解压成功')
    } catch (error) {
        console.log(error)
    }
}
main()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!