Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch File to process the "Enter" key  (Read 29353 times)

0 Members and 1 Guest are viewing this topic.

ENAREnterprises

  • Guest
Batch File to process the "Enter" key
« on: December 07, 2006, 09:06:31 PM »
I need a batch file that will process the <Enter> key after a command takes place that requires the Enter key to be pressed.

In this case, the batch file processes the unregistration of a dll and/or ocx file and the re-registration of others using "REGSVR <filename> /u" or without the /u. Then, the batch file call the underlying program that needs those dll's or ocx's.
  
Each time the unregister or register process occurs in the current batch file, the computer lists a message about it being successful (or rarely unsuccessful) and needing to press <Enter>. However, with the correct commands, and the need to use this often on a variety of files for each line of the batch file that uses the unregister and re-register commands, this is time-consuming. I need to automate this.

The normal syntax would have the "<Enter.Txt" at the end of the command line file to feed the contents of that text file (the Enter command) to the computer immediately for each line.

What is the content of the Enter.Txt file that is the equivalent of the <Enter" key? I've used this technique years ago when creating a batch file that would automatically enter a "Y" (for Yes) when formatting floppies. However, this should be either the <Enter> key or the "Carriage Return" command. However, I haven't been able to get it to work.

Any thoughts or suggestions would be appreciated.

gpl



    Apprentice
  • Thanked: 27
    Re: Batch File to process the "Enter" key
    « Reply #1 on: December 08, 2006, 01:48:15 AM »
    In the case of Enter, it would just be a plain (notepad) text file with a single blank line in

    Rather than create the file and do

    MyCommand<Enter.txt

    you could do

    Echo. | MyCommand

    Graham

    ENAREnterprises

    • Guest
    Re: Batch File to process the "Enter" key
    « Reply #2 on: December 08, 2006, 10:47:52 AM »
    I tried the suggestions Graham, but neither worked. First I tried the
    Echo. | MyCommand
    No good, it didn't change any behavior, and still required pressing enter for each line.

    Then I tried editing the text file Enter.Txt to only inlcude a blank line created by entering Enter. (I had tried that previously before posting this question.) It didn't work.

    Again, the syntax that I had been using in the batch file is:
    regsvr32 "C:\Program Files\Common Files\ MySpecial.ocx" /u <Enter.Txt
    and
    regsvr32 "C:\Program Files\Common Files\MyNewSpecial.ocx" <Enter.Txt
    Program.Exe

    I had tried your suggestion as the following:

    echo. | regsvr32 "C:\Program Files\Common Files\ . . .ocx"
    and
    echo. | regsvr32 "C:\Program Files\Common Files\ . . .ocx" /u

    Do you or does someone else have any other ideas?

    Thanks for your efforts.

    Sidewinder



      Guru

      Thanked: 139
    • Experience: Familiar
    • OS: Windows 10
    Re: Batch File to process the "Enter" key
    « Reply #3 on: December 08, 2006, 12:44:43 PM »
    Not all programs are programmed to take input from the pipe. You may be SOL on this. I even tried this with a windows script, but the problem is that when the message is sent to the screen, the program is still running and the wait for input is not on the stdin device.

    You could use the /s switch to rid yourself of the message boxes, but the errorlevel remains zero whether it's successful or not; not helpful if you need to test the result of the registration.

     :'(
    The true sign of intelligence is not knowledge but imagination.

    -- Albert Einstein

    ENAREnterprises

    • Guest
    Re: Batch File to process the "Enter" key
    « Reply #4 on: December 08, 2006, 01:43:48 PM »
    Thanks for trying.

    ENAREnterprises

    • Guest
    Re: Batch File to process the "Enter" key
    « Reply #5 on: December 08, 2006, 06:14:08 PM »
    One final thing. A friend told me the fix that made this work. It turns out that REGSVR32.EXE includes several switches, one of which is /s. It stands for "silent." In this case, it means that the system does NOT wait for input from the keyboard.

    Thus, all that was needed was to add /s to the end of each line for REGSVR32.EXE.

    I should have, but didn't think to check REGSVR32.EXE /? which would have listed the switch options. Whether I would have understood that "silent" means that no input is needed is another thing.

    Thanks again.