分享一个 powershell 脚本,一键安装本地目录准备好的软件 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
treblex
V2EX    分享创造

分享一个 powershell 脚本,一键安装本地目录准备好的软件

  •  
  •   treblex
    lazyfury 179 天前 1858 次点击
    这是一个创建于 179 天前的主题,其中的信息可能已经有所发展或是发生改变。
     # 获取当前脚本所在的目录 $scriptDirectory = $PSScriptRoot # 指定要扫描的目录(不包含子目录) $installDirectory = "$scriptDirectory\快速安装" # 这里可以指定你的安装目录 # 获取指定目录下的所有文件(不包含子目录) $filePaths = Get-ChildItem -Path $installDirectory -File # 手动添加额外的文件路径 # $filePaths += "$scriptDirectory\快速安装\VisualStudioSetup.exe" # $filePaths += "$scriptDirectory\快速安装\Adobe_Photoshop_2023_24.3.0.376_ACR15.3_SP_20230418\Adobe Photoshop 2023 SP\Set-up.exe" function Install-SetupApp{ param( [Parameter(Mandatory=$true)] [string]$filePath # 接收一个文件路径数组 ) # return if ($filePath.EndsWith(".exe") -or $filePath.EndsWith(".msi")) { # 只执行 .exe 或 .msi 文件 # 检查文件是否存在 if (Test-Path $filePath) { Write-Host "正在安装: $($filePath)" Start-Process -FilePath $filePath -Wait } else { Write-Host "文件不存在: $($filePath)" } } } # 输出文件路径数组(调试用) # $filePaths foreach($filePath in $filePaths){ if($filePath.Name.EndsWith(".exe") -or $filePath.Name.EndsWith("msi")){ Install-SetupApp -filePath $installDirectory\$filePath } } Install-SetupApp -filePath "$installDirectory\Adobe_Photoshop_2023_24.3.0.376_ACR15.3_SP_20230418\Adobe Photoshop 2023 SP\Set-up.exe" Write-Host "所有文件安装完成" 
    TrackBack
        1
    TrackBack  
       179 天前
    吾爱打过来了?这脚本随便一个 ai 都能写
    而且没有静默安装参数需要点点点的软件你怎么办
    treblex
        2
    treblex  
    OP
       179 天前
    @TrackBack 就是 gpt 辅助写的,我够用了
    treblex
        3
    treblex  
    OP
      &nbs;179 天前
    @TrackBack 7zip 这种支持静默安装,其他的自定义安装器很难支持
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3757 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 29ms UTC 10:22 PVG 18:22 LAX 02:22 JFK 05:22
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86