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

时间:2016-10-04 12:18:44

标签: powershell

我有一个脚本可以从服务器安装VLC。运行脚本时会发生什么,我的文本文件中的每个计算机名称都会启动安装过程,然后您将点击下一步"接下来的下一个" (基本上)。

我很好奇我如何为任何软件编写这些脚本来安装而不是提示所有这些脚本" next"并且只需自行安装。这可能吗?

# 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
    }
}

1 个答案:

答案 0 :(得分:3)

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

YourApiService.createService().getProfile(profile_url);

vlc-2.0.1-win32.exe /L=1033 /S 可能是 silent 安装的开关。