Question:
How to make a batch file type text in notepad?
Jonathan
2010-08-22 16:50:11 UTC
Alright so basically i made a script that can open notepad and type text in it, however what i want to do is make the VBS also launch a batch file. I've been having trouble with this only because i need both the script and the batch file to be one file, and merging the files wont work because it will either save it as .VBS or .BAT and then one or the other file doesnt work.

so...

How do i make the batch file do the same thing the script file is doing while still executing the batch file?

Here is the VBS script code i want completed:

WScript.Sleep 1800
WScript.Sleep 1000
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad"
WScript.Sleep 100
WshShell.AppActivate "Notepad"
WScript.Sleep 500
WshShell.SendKeys "Hel"
WScript.Sleep 500
WshShell.SendKeys "lo "
WScript.Sleep 500
WshShell.SendKeys ", ho"
WScript.Sleep 500
WshShell.SendKeys "w a"
WScript.Sleep 500
WshShell.SendKeys "re "
WScript.Sleep 500
WshShell.SendKeys "you"
WScript.Sleep 500
WshShell.SendKeys "? "
WScript.Sleep 500
WshShell.SendKeys "I a"
WScript.Sleep 500
WshShell.SendKeys "m g"
WScript.Sleep 500
WshShell.SendKeys "ood"
WScript.Sleep 500
WshShell.SendKeys " th"
WScript.Sleep 500
WshShell.SendKeys "ank"
WScript.Sleep 500
WshShell.SendKeys "s! "
WScript.Sleep 500
WshShell.SendKeys "So "
WScript.Sleep 500
WshShell.SendKeys "Yo"
WScript.Sleep 500
WshShell.SendKeys "u'r"
WScript.Sleep 500
WshShell.SendKeys "e Pro"
WScript.Sleep 500
WshShell.SendKeys "bab"
WScript.Sleep 500
WshShell.SendKeys "ly "
WScript.Sleep 500
WshShell.SendKeys "Won"
WScript.Sleep 500
WshShell.SendKeys "de"
WScript.Sleep 500
WshShell.SendKeys "ri"
WScript.Sleep 500
WshShell.SendKeys "ng Wh"
WScript.Sleep 500
WshShell.SendKeys "at"
WScript.Sleep 500
WshShell.SendKeys " The "
WScript.Sleep 500
WshShell.SendKeys "He"
WScript.Sleep 500
WshShell.SendKeys "ll "
WScript.Sleep 500
WshShell.SendKeys "is "
WScript.Sleep 500
WshShell.SendKeys "go"
WScript.Sleep 500
WshShell.SendKeys "in"
WScript.Sleep 500
WshShell.SendKeys "g O"
WScript.Sleep 500
WshShell.SendKeys "n, "
WScript.Sleep 500
WshShell.SendKeys "To"
WScript.Sleep 500
WshShell.SendKeys "o B"
WScript.Sleep 500
WshShell.SendKeys "ad..."
WScript.Sleep 1000
WshShell.SendKeys " "
WScript.Sleep 500
WshShell.SendKeys "Virus Loading."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "."
WScript.Sleep 500
WshShell.SendKeys "Complete! "
WScript.Sleep 500
WshShell.SendKeys "Ha"
WScript.Sleep 500
WshShell.SendKeys "ve "
WScript.Sleep 500
WshShell.SendKeys "a "
WScript.Sleep 500
WshShell.SendKeys "Ni"
WScript.Sleep 500
WshShell.SendKeys "ce "
WScript.Sleep 500
WshShell.SendKeys "Life."
Three answers:
2010-08-23 17:58:00 UTC
You cant really get a batch file to do what you are looking for, but what you asked for is the 'echo' command.

eg.



echo This is the text I want displayed



Or, you could do a plain line (double enter) in the following way:



echo.



Note the fullstop instead of the space.



And the pause can be done by pinging the local host as follows:



ping -n 2 127.0.0.1



(Something like that)

Just go into cmd.exe and type ping/?



Good luck!

Shane Thompson
2010-08-22 17:34:18 UTC
You can't have bat language and vb language script in the same file.
2016-04-20 06:11:03 UTC
@echo off rem This batch file will create abc.txt and def.txt with rem lines of text written to the files. cls cd "%userprofile%\Desktop" echo this is the first line of text > "abc.txt" echo this is the second line >> "abc.txt" echo this is the third line >> "abc.txt" echo this is the fourth line >> "abc.txt" echo this is the last line of text >> "abc.txt" rem New text file to be created echo This is a new line of text to a new file > "def.txt" echo this is a second line of text to def.txt >> "def.txt" echo last line of text >> "def.txt" echo Abc.txt and def.txt has been created on your desktop. pause >nul exit You can even create batch files with this method: @echo off cls cd "%userprofile%\Desktop" echo @echo off > "batfile1.bat" echo cls >> "batfile1.bat" echo Hello World >> "batfile1.bat" echo pause >> "batfile1.bat" echo exit >> "batfile1.bat" echo batfile1.bat has been created on your desktop. echo. pause exit


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...