-1

I am calling a program using batch file which Pops-up a cmd window. I need to refresh it every 30 seconds and I can do it manually by writing R in the cmd. I want to automate it now.

Solution I expect:

  • look for this program in tasklist every 30 seconds (done)
  • invoke/access it from tasklist and write R (do not know how to implement)

Code (file: run_myapp.bat):

set appName=MyApp.exe
call C:\Scripts\%appName% "0" "Blue"
wait 2000
::
:ReFresh
tasklist /FI "IMAGENAME eq appName" 2>NUL | find /I /N "appName">NUL
if "%ERRORLEVEL%"=="0" (
...
**rem I need some code here to access/invoke the app from tasklist and write R in it**
...
echo Last refreshed at %time%
wait 30000
goto :ReFresh
)
aly
  • 17
  • 5
  • 1
    This question is unclear. what console accepts the R as refresh command, is it cmd window, 3rd part window etc etc. – Gerhard Feb 07 '19 at 08:17
  • It a custom program which accepts writeing R in the cmd to refresh it. In description as well I wrote that I write R in cmd window for refreshing. – aly Feb 07 '19 at 08:55
  • Then why not show that code, then perhaps I can help? – Gerhard Feb 07 '19 at 09:00
  • @GerhardBarnard I have added the Code. Please have a look. Thanks – aly Feb 07 '19 at 09:17
  • So when I run this batch file, it Pops up a new cmd window which Shows the app Status. So I want to refresh the app.exe cmd window automatically, which currently I do manually by writing R in it. – aly Feb 07 '19 at 09:28
  • Is the second file an batch file as well? Please help and give all you can so I can help you. – Gerhard Feb 07 '19 at 09:31
  • Please include all relevant information into the question by [edit]ing it! So basically you are looking for a way to send a key-stroke to the console window that runs `MyApp.exe`, right? you cannot do that with pure batch scripting; you need to borrow from another language like JScript or VBScript, for example; perhaps you are interested in [sendKeys.bat](https://github.com/npocmaka/batch.scripts/blob/master/hybrids/jscript/sendKeys.bat); also take a look at this question: [Press Keyboard keys using a batch file](https://stackoverflow.com/q/17038282)... – aschipfl Feb 07 '19 at 09:33
  • @aschipfl you are write, it is a 3rd-party .exe file which I am running and I do not know in which language they have written it. What I just know is when I execute it using batch, it Pops up a cmd window and I can see it in tasklist as well. I am running this app in Windows Server. – aly Feb 07 '19 at 09:34

1 Answers1

0

include CreateObject("WScript.Shell"):shell.SendKeys

add {r} as button then made some loop for useing again your $ReFresh