call enter in .bat file - batch-file

I call .bat file from remote machine. In this .bat file I call .exe file, which want user to press Enter, after this .exe worked.
So, my question: is there any option to pass Enter in .bat file? Thanks for any help.
code of my .bat file
pushd \\server_name\\myfolder\\Reports\\
reportsupload.exe -e "http://mysite/ReportServer"
popd

If you are looking for a solution that does not rely on third-party programs, that will depend on how the program reportsupload.exe handles the request for pressing ENTER. If it reads the standard input stream, you might be able to manage it by changing the line to echo. | reportsupload.exe -e "http://mysite/ReportServer"; if it's handled by scanning the keyboard for the keypress, this will not work.
There may be third-party programs that can be configured to detect when the computer or a program is in a given state and trigger an action based on that state, but I'm not aware of any that don't require user intervention (e.g., pressing a key to execute a macro).

Related

How to disable input in batch script?

I have a batch script (mine) that launches another batch script (theirs). Their batch script queries user input as part of the process, and I do not have access to modify it.
I need to suppress their batch script from querying input, meaning that when their batch script outputs: Press enter for step 2..., I want the user to be unable to interact with the script using their keyboard, hence the script should look like it's frozen.
How do I call their script from my script in such a way that the user is unable to interact with the input requests of their script?
Actually summing up the comments to make this not an unanswered question. You can try using the | (pipe) operator:
echo Haha! You will not be able to press any key!! | their.bat
Which will redirect STDOUT (Standard Out) of command echo Haha! You will not be able to press any key!! (Haha! You will not be able to press any key!!) to STDIN (Standard Input) of command theirs.bat.
Or, even read from nul:
their.bat < nul
I recommend reading https://ss64.com/nt/syntax-redirection.html and What does "&&" in this batch file? (second answer is better here.).

Using batch file to control dos user input

I'm using a program called lewice that runs in a dos window.
When you run the program it requires 'user input' to give a file name for the input files.
Is there anyway I can get a batch file to send the commands to the dos window so the batch file can by default use file name x?
Thanks
Not sure if that's what you want but maybe lewice can use inputs parameters, you just have to create a shortcut and add options:
https://superuser.com/questions/29569/how-to-add-command-line-options-to-shortcut
It might get trickier if the path to the file has spaces.

batch file start a program when closed

I need help writing a batch file that starts a program when I close the Command Prompt (batch file).
I know how to start a program when the batch file is running:
#echo off
Start [adress of application]
I believe it's not possible, because when you terminate the batch (by pressing the red 'X' on top), it will end imediately without doing anything.
But you can Read the user input, and if the user writes "Exit", it will run a program and close. I think you don't want that, but If you, then look at this: In Windows cmd, how do I prompt for user input and use the result in another command?

Batch Files - Closing Opened Text Files

I currently have a Windows batch file that runs an .exe file that uses a text file. I am trying to have the Windows batch file run the .exe file multiple times. This, however, requires the use of the same text files to read from. The command prompt gives me the error that the ".txt could not be opened" (I assume from this that it is already open.)
I am trying to see if there is a way in a .bat file to system call to kill that specific text file. The suggestions I see online are to use 'taskkill notepad.exe', but that returns "invalid argument" because the program doesn't open Notepad to use the text file.
Any suggestions would be appreciated.
It sounds like your existing script fails because the first instance of the exe is still open when the second instance starts.
One thing worth trying (and this depends on the nature of the application you are invoking) is to start the executable using the START /WAIT /B ... command. This makes the command interpreter wait for the program to exit before it moves onto the next command, so as long as nothing else is locking the text files you should be OK to move onto the next command.

getting returned results after running .BAT file

when i run a .BAT file, it displays a message but immediately closes the window
how i can i force it to keep the window open so that i can see the message reeturned?
One way is to conclude the batch file with the
PAUSE
command.
You can also wrap it another batch file that calls the original and then pauses:
FOO.BAT
PAUSE
This also works for read-only batch files and compiled executables.
An alternative is to execute this bat file from an already opened command prompt (shortcut: Windows Key + R, type cmd, press ENTER)

Resources