I want to check if the cmd.exe + window of it is running, if it is running I want to put the window to the foreground, but somehow this does not work: Local $sCommandlinePath = "C:\Windows\system32\cmd.exe"
RunCm()
Func RunCm()
If FileExists($sCommandlinePath) Then
If ProcessExists("cmd.exe") Then
If WinExists("[CLASS:ConsoleWindowClass]") And WinActive("[CLASS:ConsoleWindowClass]") Then
Local $hCmdWindow = WinGetHandle("[CLASS:ConsoleWindowClass]")
WinSetOnTop($hCmdWindow, "", $WINDOWS_ONTOP)
EndIf
Else
Local $iCmMax = Run($sCommandlinePath, "", @SW_SHOWMAXIMIZED)
EndIf
EndIf
EndFuncI started the command line and put another window above it then I started my script and it did not put the command line window to the foreground.