EM90210
EM90210

Reputation: 135

Command Prompt auto confirm message pop up window

I'm running a batch file that runs a command line, mid way in the command, there is a message pop up where once has to press "OK" in order to continue processing the command. Is there something I can add that would auto confirm this pop up?

Upvotes: 2

Views: 17290

Answers (1)

npocmaka
npocmaka

Reputation: 57262

Check this sendKeys.bat.It accepts two arguments - window title where keys will be sent and a string with a keys which will be "pressed" (microsoft reference with of the SendKeys function) .Here's example how it can be used to close Yes/No and Ok pop-ups:

C:\>start "" /min powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show("""HelloWorld""", """My PopUp Message Box""",4)
C:\>call sendkeys.bat "My PopUp Message" "Y"

or

C:\>start "" /min powershell [Reflection.Assembly]::LoadWithPartialName("""System.Windows.Forms""");[Windows.Forms.MessageBox]::show("""HelloWorld""", """My PopUp Message Box""")
C:\>call sendkeys.bat "My PopUp Message" "{ENTER}"

EDIT .not tested:

@echo off

:repeat
w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:10  >nul 2>&1
call sendkeys.bat "Some Title" "Y" || (
    goto :repeat
)&&(
    goto :end
)
:end

this will try to send keys on every 10 seconds.

Upvotes: 1

Related Questions