Add-Type @" using System; using System.Runtime.InteropServices; public class Util { [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); } "@ $wshell = New-Object -ComObject wscript.shell; foreach($i in $args){ $app = Start-Process -FilePath $i -passThru -Verb Print start-sleep -m 200 $wshell.AppActivate($app.Id) #start-sleep -m 200 $wshell.SendKeys('{ENTER}') #Wait-Process -InputObject $app #start-sleep -m 200 } sleep 10 exit