Board logo

标题: [系统相关] 求生成电脑安装软件清单及对应文件安装目录的bat脚本 [打印本页]

作者: 联想不是你的    时间: 2024-1-17 16:04     标题: 求生成电脑安装软件清单及对应文件安装目录的bat脚本

求一个可以生成电脑安装软件清单及对应文件安装目录的bat
作者: Batcher    时间: 2024-1-17 22:08

回复 1# 联想不是你的


    Win7? Win10? Win11?
作者: ShowCode    时间: 2024-1-18 08:42

回复 1# 联想不是你的


V1.bat
  1. # & cls & @cd /d "%~dp0" & powershell -c "Get-Content '%~0' | Out-String | Invoke-Expression " & pause & exit /b
  2. function Get-InstalledSoftwares
  3. {
  4.     #
  5.     # Read registry key as product entity.
  6.     #
  7.     function ConvertTo-ProductEntity
  8.     {
  9.         param([Microsoft.Win32.RegistryKey]$RegKey)
  10.         $product = '' | select Name,Publisher,Version
  11.         $product.Name =  $_.GetValue("DisplayName")
  12.         $product.Publisher = $_.GetValue("Publisher")
  13.         $product.Version =  $_.GetValue("DisplayVersion")
  14.         if( -not [string]::IsNullOrEmpty($product.Name)){
  15.             $product
  16.         }
  17.     }
  18.     $UninstallPaths = @(,
  19.     # For local machine.
  20.     'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
  21.     # For current user.
  22.     'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall')
  23.     # For 32bit softwares that were installed on 64bit operating system.
  24.     if([Environment]::Is64BitOperatingSystem) {
  25.         $UninstallPaths += 'HKLM:SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
  26.     }
  27.     $UninstallPaths | foreach {
  28.         Get-ChildItem $_ | foreach {
  29.             ConvertTo-ProductEntity -RegKey $_
  30.         }
  31.     }
  32. }
  33. Get-InstalledSoftwares
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2