Você pode tentar este script do powershell. Ajuste $exe
caminho, se necessário.
# Your executable here
# $exe = "notepad"
$exe = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
function Set-TopMost($handle) {
$FnDef = '
[DllImport("user32.dll")]
public static extern bool SetWindowPos(int hWnd, int hAfter, int x, int y, int cx, int cy, uint Flags);
';
$user32 = Add-Type -MemberDefinition $FnDef -Name 'User32' -Namespace 'Win32' -PassThru
$user32::SetWindowPos($handle, -1, 0,0,0,0, 3)
}
$pname = [System.IO.Path]::GetFileNameWithoutExtension($exe)
$p = (Get-Process $pname -ErrorAction "SilentlyContinue") | ? { $_.MainWindowHandle -ne 0 }
if ($p -eq $null) {
Write-Host "Process '$pname' not found, starting: $exe"
& $exe
Write-Host "Waiting for process '$pname'"
while ($p -eq $null) {
sleep -Milliseconds 100
$p = (Get-Process $pname -ErrorAction "SilentlyContinue") | ? { $_.MainWindowHandle -ne 0 }
}
}
$p.MainWindowHandle
Set-TopMost $p.MainWindowHandle