For example, if I execute a "start /w PKGMGR /iu:" installation command, If the execution has not been completed for more than ten minutes, a prompt will pop up. How do I set the timeout and prompt?
For example, if I execute a "start /w PKGMGR /iu:" installation command, If the execution has not been completed for more than ten minutes, a prompt will pop up. How do I set the timeout and prompt?
Hi @heyangben-3420 ,
The openspec-* tags are dedicated to supporting issues related to open specifications. You can find open specifications here https://docs.microsoft.com/en-us/openspecs/
Since your question does not pertain to one of these specifications, I've removed the openspecs-windows tag and added the windows-server-powershell tag. Hopefully this will get your post the proper attention.
If I've misunderstood your question and you believe this is related to the Open Specifications documents, please clarify, providing the document name and section with which you have the question or issue.
Best Regards,
Michael Bowen
Escalation Engineer - Microsoft Open Specifications
You will need to use Powershell to do that.
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$process = Start-Process "PkgMgr.exe" -PassThru
$StartTime = Get-Date
Write-Host "You have 15 seconds to do something."
while ($true) {
if ($process.HasExited) {
Write-Host "It ended."
break
}
Start-Sleep 5
Write-Host "Testing."
$ts = New-TimeSpan –Start $StartTime –End (Get-Date)
if ($ts.TotalSeconds -gt 15) {
$oReturn=[System.Windows.Forms.Messagebox]::Show("What is taking so long??????")
Write-Host "You took too long."
$process.Kill()
break
}
}
This site shows how to generate a prompt.
https://michlstechblog.info/blog/powershell-show-a-messagebox/
Think you very much
But I want to be able to achieve in the Win7 system
Win7 can achieve it?
It should, but I no longer have a Win7 machine to test with. Open Powershell_ISE and paste the script into a code window and run it.

16 people are following this question.