How do I make a text file appear to type itself using a batch file?

batch file commands
batch file examples
batch file keyboard input
batch script type command
create batch file to run exe
batch file enter text automatically
batch file create text file
batch file to enter text in a program

What I'm trying to achieve is for my Batch file to open Notepad and start typing automatically. Here's my code so far:

@echo off
Start notepad

but where do I go from here? I've tried:

@echo off
Start notepad
type "stuff" 
exit

and similar things but it didn't work.

Is there a way to do that in Batch?

Here's a little toy I whipped up to type out the text that's in the lineN variables, in a quasi-human style, to the console screen.

See the code for a tip on how to speed it up or slow it down.

@echo off
:: Ghost typer
setlocal enableextensions enabledelayedexpansion

set lines=6


set "line1=Twinkle twinkle little star"
set "line2=How I wonder what you are"
set "line3=Up above the world so high"
set "line4=Like a diamond in the sky"
set "line5=Twinkle twinkle little star"
set "line6=How I wonder what you are"


for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"

for /L %%a in (1,1,%lines%) do set num=0&set "line=!line%%a!"&call :type

pause>nul
goto :EOF

:type
set "letter=!line:~%num%,1!"
set "delay=%random%%random%%random%%random%%random%%random%%random%"
set "delay=%delay:~-6%"
if not "%letter%"=="" set /p "=a%bs%%letter%" <nul

:: adjust the 3 in the line below: higher is faster typing speed

for /L %%b in (1,3,%delay%) do rem
if "%letter%"=="" echo.&goto :EOF
set /a num+=1
goto :type

How to Create a Batch (BAT) File in Five Simple Steps, This article covers how to create a batch file using five simple steps for the Windows operating Duration: 3:20 Posted: Aug 27, 2016 By: Judago January 16, 2011. Specifically for cmd.exe on Windows Operating Systems. It is a common occurrence in the Programming Forum to see questions related to creating text files with a batch script, be it to create a secondary script or a particular format of text file.

This would be -- umm I don't know if even possible in Batch. BUT, you could do this in one file if you code it in VBScript.

set ghost = wscript.CreateObject("WScript.Shell")

ghost.run "notepad"
wscript.sleep 3000
ghost.sendkeys "Hello."
wscript.sleep 1000
ghost.sendkeys "I am a magical ghost "
wscript.sleep 1000
ghost.sendkeys "who possesed your keyboard."

You save this as .vbs instead of .bat!

Explanation:

set ghost = wsc .... bla bla bla

- Creates a new WSCRIPTShell object (which is required for opening notepad AND "posessing" your keyboard"

ghost.run "notepad"

- Opens notepad.

wscript.sleep 3000

- "Sleeps" for 3000 milliseconds (That's 3 seconds)

ghost.sendkeys "Hello."

- Types "Hello." (Without quotes of course.)

It should be easy to adapt this to your needs. EDIT: "Sleeping" aka pausing is ALWAYS in milliseconds. You get milliseconds by multiplying seconds by 1000. E.g. 1 Second = 1000 Milliseconds Because 1 * 1000 = 1000

Evil Self Duplicating Batch File : 3 Steps, Have you ever wanted an evil batch file that opens itself again and again and 3 The words after echo are what show up on the screen (you can change this Ctrl + S and type America.bat (name it what you typed earlier) in the text field and� If you use DIR to display file sizes, files being downloaded seem to have a file size of 0 bytes. By using TYPE once to display the contents of the file, next time DIR will show the actual amount of bytes already downloaded. This won't hurt the download, since TYPE does in no way lock the file. Use TYPE and DIR again to check on download progress:

Set wshShell = wscript.CreateObject("WScript.Shell")
do
wscript.sleep 100
wshshell.sendkeys "{}"
loop

If you type in a Key on the keyboard in CAPS in between the {} you can make it continuously type that letter!

BTW save this as as .vbs file instead of a batch file.

Batch file basics, Batch files or scripts are small easy-to-write text files that carry out a series of simple text files containing some lines with commands that get executed in sequence, off the display for the whole script, except for the "echo off" command itself. The idea is to show how simple they are and to intrigue readers to look further� Save the file as a text file. You can also create a text file using any other word processing software program, like Microsoft Word or WordPad. When saving the file, change the file name or file type to Plain Text to save it as a text file. In many of these programs, you'll also have the option to save the file as a Rich Text Format.

@echo off
echo Hello what is you name?
set /p %name%= 
echo>Hello%name%.txt I have just taken over you computer.
:: the set command works in this format
:: The above echo will not show up in a command prompt if echo is off 
:: You must use "echo >" for the batch file to create a text file
:: The word that you put immediately after the ">" will be the name of the file
:: you can also use a "%-%" command for the file name.
:: The batch file will create a new text file for each "echo >" command used
:: So if you want a lot of text in one document write all of the text on one line
:: P.S. I found this by accident while creating an inventory program XD

How to Write a CMD Script, If you have every used the Command Line, or CMD, interface in Windows, you probably was released, when you wanted to run a script, you would save it as a .bat file. The text file will appear in the same folder where the script file itself is. The TEXT command is useful for displaying menus, tables, special characters, or multiline messages. TEXT will display all lines in the batch file between itself and the terminating ENDTEXT. The display starts at the current display position, which allows you to start its display with other text, e.g., from the ECHOS command.

Lookup the "pv" command and check the option "-L"

" Data Transfer Modifiers

-L RATE, --rate-limit RATE Limit the transfer to a maximum of RATE bytes per second. A suffix of "k", "m", "g", or "t" can be added to denote kilobytes (*1024), megabytes, and so on. "

SO...

echo "twinkle twinkle little star

> how I wonder what you are" | pv -qL 10

http://www.ivarch.com/programs/yum.shtml

Batch files - The TYPE command, TYPE has at least one feature that makes it well text file viewing: it doesn't lock the file it views. Take a look at the example: will be identical to logfile.log's, though it will have a� Edit the batch file's contents. At any time, you can right-click your batch file and click Edit in the resulting drop-down menu. This will open the batch file as a Notepad document; at this point, you can make any changes and then save the file by pressing Ctrl+S. The changes will immediately be reflected when you run the batch file.

Batch file pause and continue, Here is how you can create a batch file which will auto elevate itself. Press any key when readyWell, your batch file will pause and a message will appear. In DOS, OS/2, and Windows, a batch file is a type of script file, a text file containing� Open the notepad. Type all the commands that you wish you write. go to File -> save as -> under save as type select "All files" now type the name with extension .bat example : example.bat and click on save. That should do it.Let us know.

Generate a Backup File with Timestamp using a Batch Script, If so, in this tutorial I'll show you the steps to create backup files using a batch script. File Type" "Path where your backup file will be stored\%BackupName%. And this is how the Notepad would look like after copying the above code: Design tab, press on the “button shape” and then place the button on the Form itself:. I want to read text file using batch script, i have a log file which contain some data and i want to read BUILD number from that text file and display. Example : Build:2016.17.05_0872 is there an

Batch Script - Quick Guide, Batch scripts are stored in simple text files containing lines with commands that get These files have the special extension BAT or CMD. Files This is a batch command that associates an extension with a file type The command "echo off" turns off the display for the whole script, except for the "echo off" command itself. If this batch file were called pingme.bat, and I type pingme.bat yahoo.com, then it would ping yahoo.com. My problem is I want the batch file to accept input from a text file. For example, pingme.bat computers.txt would read the names of computers listed in the computers.txt file, and do whatever command I specified to be done to them.

Comments
  • you're not going to accomplish this with a .bat file. That's WAY beyond what they're intended to do
  • You should look into vbscript and using the sendkeys function
  • It works like a charm! :) But would it be possible to explain what for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "BS=%%a"? Without it an extra character is always printed after each letter so the backspace you set as prompt with prompt $H is used somehow but I can't figure out how and what that for /f loop, the for-loop and the BS variable are for.
  • @J.Baoby Late comment for foxidrive (R.I.P) That line generates a backspace in BS since set /p will drop single space prompts an additional char is print first then BS and the intended char.