3

First, I do not know how to work with this kind of thing, let alone programming, but this site has helped me build everything I've done so far, so I came to ask a question. I want to make a batch file that opens an .exe and type a command in it. The executable file looks a lot like a cmd ...Program running the startup commands. After finishing initializing the program's plugins, it allows me to type some commands. The command in question that I want to execute is "overlay osu" (To open the game with the plugin enabled). I started with start to open the command and a timeout / t 4 to wait for the program to initialize properly, but I do not know how to make the batch file enter some command in the program after a certain time (4 seconds in that case). My command for now goes on like this:

ECHO OFF
start Sync.exe
timeout / t 4> nul

timeout / t 7> nul
exit

The empty line would be to place the command. I came to think that it would be possible if instead of opening the program in another window, try to open a new cmd and open the program inside the cmd itself with this command:

ECHO OFF
start cmd @cmd /k sync
timeout / t 4> nul

timeout / t 7> nul
exit

But anyway I do not know a command to type what I want in another program. As I said, I'm no expert, I'm just a 15-year-old boy too lazy to open the documents and type a command every time he wants to play, so any help is welcome. If it is not possible to do this type of task in a .bat, tell me in what kind of language it would be possible to program it, I will do my best to learn the basics. With everything said, I don't need the program to be closed after this, only the batch file! (sorry for anything, I do not use forums often and English is not my primary language)

0

So, can you try send key (VBS)


| Send_Enter.cmd |


@echo off 

>"%temp%\_send_enter.vbs"^
     (
      echo/ Set objShell = WScript.CreateObject^("WScript.Shell"^)
      echo/ Set WshShell = WScript.CreateObject^("WScript.Shell"^)
      echo/ objShell.AppActivate "Sync"
      echo/ Wscript.Sleep 4000
      echo/ WshShell.SendKeys "({ENTER})"
     )

set _Run_CScript="%Windir%\System32\CScript.exe" "%temp%\_send_enter.vbs" //nologo

tasklist|find /i "Sync.exe" >nul && start "" /b %_Run_CScript%

:loop
rem :: way to get out of script :: 
tasklist|find /i "Sync.exe" >nul && (timeout / t 7> nul & goto :loop) || exit /b 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.