2014-01-09 86 views
0

我正在写一个PowerShell脚本来自动化一些更新。Powershell通过“按任意键继续”从另一个脚本

为此,我需要执行另一个脚本并将输出保存到一个变量中。

之后,我可以将我需要的东西剪掉并保存到其他变量中。

这些事情在理论上是有效的,但我正在执行的另一个脚本会停止该进程,因为它需要任何密钥才能在最后继续。

有人知道我怎么能通过这个?

脚本停止后:

$list = .\list.cmd 

亲切的问候:)

那是脚本的一部分:

Write-Host "Importing..." 
cd "$path" 
$list = .\list.cmd 

Write-Host "Searching for the certificate file" 
$CertificateFile = $list | where {$_ -match "Certificate File:"} 
$CertificateFile = $CertificateFile.Substring(18) 

Write-Host "I'm trying to find the Password File:" 
$PasswordFile = $PasswordFile = $list | where {$_ -match "Password File:"} 
$PasswordFile.Substring(15) 

Write-Host "Searching for the password file" 
$Enddate = $list | where {$_ -match "Validity NotAfter:"} 
$Enddate = $Enddate.Substring(19) 
+0

你能发表list.cmd的内容吗? – mjolinor

+0

只是改变list.cmd,所以它不需要按键? – Paul

+0

你能分享一下你的总体目标吗?很有可能在PowerShell中这样做,而无需调用cmd.exe,尤其是考虑到您正在处理X.509证书管理工作。 –

回答

0

这里是你如何发送击键。至于时间安排,当暂停的应用程序处于前景“活动”窗口时,需要进行定时。

add-type -AssemblyName System.Windows.Forms 
[System.Windows.Forms.SendKeys]::SendWait("A") 
+0

嗨 感谢您的发布。我认为在定义的时间之后发送按键并不是一种解决方案,在unix中是否有类似的期望? http://linux.die.net/man/1/expect – lucbas