powershell - 安装VLC自动安装,无需点击下一步

标签 powershell

我有一个将从服务器安装 VLC 的脚本。当我运行脚本时会发生什么,我的文本文件中的每台计算机名称都将开始安装过程,然后您将点击“下一步下一个”(基本上)。

我很好奇如何为任何软件编写这些脚本来安装,而不是提示所有这些“下一步”,而是自行安装。这可以吗?

# Run As Administrator

Function Get-FileName{
[CmdletBinding()]
Param(
    [String]$Filter = "|*.*",
    [String]$InitialDirectory = "C:\")

    [void][System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")
    $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    $OpenFileDialog.initialDirectory = $InitialDirectory
    $OpenFileDialog.filter = $Filter
    [void]$OpenFileDialog.ShowDialog()
    $OpenFileDialog.filename
}

$file = Get-FileName -InitialDirectory $env:USERPROFILE\Desktop -Filter "Text files (*.txt)|*.txt|All files (*.*)|*.*"
ForEach ($item in (Get-Content $file)) {
    $sitem = $item.Split("|")
    $computer = $sitem[0].Trim()
    $user = $sitem[1].Trim()

    $filepath = Test-Path -Path "\\$computer\c$\Program Files (x86)\VideoLAN\VLC\"
    If ($filepath -eq $false) {
    Get-Service remoteregistry -ComputerName $computer | Start-Service

    Copy-Item -Path "\\server\Unsupported Software\VLC MediaPlayer" -Destination "\\$computer\c$\windows\temp\" -Container -Recurse -Force

    $InstallString = '"C:\windows\temp\VLC MediaPlayer\vlc-2.2.1-win32.exe"'
    ([WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process").Create($InstallString)

    "$computer" + "-" + "$(Get-Date)" | Out-File -FilePath "\\server\Unsupported Software\VLC MediaPlayer\RemoteInstallfile.txt" -Append

    } Else {
        "$computer" + "_Already_Had_Software_" + "$(Get-Date)" | Out-File -FilePath "\\server\Unsupported Software\VLC MediaPlayer\RemoteInstallfile.txt" -Append
    }
}

最佳答案

根据documentation ,您可以使用命令行开关来安装 VLC,例如:

vlc-2.0.1-win32.exe /L=1033 /S

其中 /S 可能是静默安装的开关。

关于powershell - 安装VLC自动安装,无需点击下一步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39852143/

相关文章:

powershell - 如何处理文件路径中的空格

powershell - 文件的 PS SHA512 哈希,输出为 base 64 编码字符串

powershell - 按版本限制 Powershell 命令

powershell - 如何从 New-KMSDataKey 返回的 "Plaintext"属性的内存流中读取?

powershell - 如何检查MS部署是否正常工作

PowerShell FTP 上传

powershell - 枚举 PSCustomObject 作为键/值对

shell - 遍历文本文件并查找不在所有文件中的行

powershell - 如何在 powershell 中以预定义字符串分割非常大的文本文件 (4GB) 并快速完成

Powershell 脚本无法将 Register-ScheduledJob 作为 Azure 资源管理器 CustomScriptExtension 执行