【问题标题】:Extraction 7zip script doesn't work in Windows Server 2019 Task Scheduler提取 7zip 脚本在 Windows Server 2019 任务计划程序中不起作用
【发布时间】:2020-03-07 07:04:20
【问题描述】:

我创建了一个 ps1 脚本来提取一个 3Gb 的 zip 文件夹。每当我从 PowerShell ISE 运行它时它就可以工作,但是当我将脚本添加到 Windows Server 2019 任务计划程序时,它只是说正在运行,它什么也没做。

我试过了

set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
Set-location C:\
sz x -oC:/ test.zip

我也试过

setx path "%path%;C:\Program Files\7-Zip"
Set-location C:\
7z x test.zip -oc:\ -r

我希望提取 3gbs 文件夹。

【问题讨论】:

  • 请复制并粘贴在 Windows 任务计划程序中输入的命令。
  • schtasks /create /tn "Extract" /sc onstart /delay 0000:30 /rl 最高 /ru system /tr "powershell.exe -file C:\scripts\setup\test.ps1"

标签: powershell amazon-ec2 7zip taskscheduler windows-server-2019


【解决方案1】:

我可以这样解决:

Add-Type -Assembly "System.IO.Compression.Filesystem"
[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\test.zip','C:\')

以及我创建任务计划程序的方式:

schtasks /create /tn "Extract" /sc onstart /delay 0000:30 /rl highest /ru system /tr "powershell.exe -file C:\scripts\setup\test.ps1"

提取一个 3GB 的文件夹需要 4 分钟。 我在这里找到了解决方案: https://ridicurious.com/2019/07/29/3-ways-to-unzip-compressed-files-using-powershell/

【讨论】:

    猜你喜欢
    • 2023-02-07
    • 1970-01-01
    • 2012-09-27
    • 1970-01-01
    • 2012-06-05
    • 2018-11-26
    • 2018-07-02
    • 2013-04-05
    相关资源
    最近更新 更多