Batch File to automatically run a setup

December 2016




Issue

I'm creating a batch file to automatically run an setup.exe, the setup.exe requires Enter to be pressed once and then runs without assistance. Is it possible to have the batch file run the .exe and then automatically select enter for me?

Solution

To do this please follow the instructions below
  • Open notepad and paste this:


@echo off 
echo Press any key
pause>nul
echo what is your username?
set /p user=
echo what is your password?
set /p pass=
If '%user%'=='Tspider4' goto gooduser
echo WRONG USERNAME AND PASSWORD
echo Press a key to exit
pause>nul
:gooduser
If '%pass%'=='youtube' goto good
echo WRONG PASSWORD
echo Press a key to exit
pause>nul
:good
echo GOOD
echo Wanna start notepad!?
set /p note=
If '%note%'=='yes' start notepad.exe
echo byebye
pause>nule
exit
  • Click save as
  • Give the name "Program.bat"
  • When you open this file you just follow what the batch file is asking you


"Press any key"

"what is your user name?"
(type this) Tspider4
"what is your password"
(type this) youtube
GOOD
Wanna start notepad?
(type this) yes



(and notepad will open automatically....) now if u wish to open WINDOWS LIVE MESSENGER u just ha to rewrite this "echo Wanna start notepad!?" for "echo Wanna start msnmgr!?"

and rewrite this
"If '%note%'=='yes' start notepad.exe"
for
"If '%note%'=='yes' start msnmgr.exe"


To know more about using notepad for creating batch files click here:
http://ccm.net/faq/1050-write-in-a-batch-file-in-text-mode

Note

Thanks to PuPp3t for this tip on the forum.

Related :

This document entitled « Batch File to automatically run a setup » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.