我正在嘗試在 Powershell 中自動連接 Anydesk 會話。
根據他們的CLI 檔案,您可以使用 echo 傳遞密碼。
現在,我正在開始這樣的程序,因為之后我需要行程 ID。
$app = Start-Process $config.anydesk_path -ArgumentList @($config.ip_addresses[$i], "--plain") -passthr
我試過像這樣將密碼附加到引數串列中
$app = Start-Process $config.anydesk_path -ArgumentList @($config.connect_pw, $config.ip_addresses[$i], "--plain", "--with-password") -passthru
但這似乎沒有輸入密碼。
有沒有辦法用 Start-Process 發送密碼?
謝謝。
uj5u.com熱心網友回復:
遺憾的是,Start-Process只能接受來自檔案的輸入(參見-RedirectStandardInput引數)。
您可以直接使用 .NET Framework Process類:
$AnyDesk = New-Object System.Diagnostics.Process
$AnyDesk.StartInfo.FileName = $config.anydesk_path
$AnyDesk.StartInfo.UseShellExecute = $false
# This allows writing to a standard input stream:
$AnyDesk.StartInfo.RedirectStandardInput = $true
$AnyDesk.StartInfo.Arguments = "$($config.ip_addresses[$i]) --plain --with-password"
$AnyDesk.Start()
# Write a password into standard input stream:
$AnyDesk.StandardInput.WriteLine($config.connect_pw)
# Grab a process ID:
$AnyDesk.Id
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/370378.html
標籤:电源外壳
