I want a batch file that will launch a continuous loop of cmd with and echo message
I can do it without echo with this code
#echo off
:1
start
GOTO 1
but all I want is that the every opened cmd window should give an echo message like "hello".
Here This Might Do It For You. (Remove The Spaces Between The Codes)
#echo off
echo (Your Message Here)
start (batfilename).bat
(batfilename).bat
Related
I'm tryng to write a batch file which starts programs, but two problems arise:
If I use one command, it opens the others (i.e. If I open the calculator, it also opens the curler
Here is the code for my program:
#echo off
cls
title Console
:prompt
set /p prompt=:
goto %prompt%
:help
echo Commands
echo ---------------
echo help........................Shows this list
echo calc........................Starts the CMD Calculator
echo retaskbar...................Starts the Taskbar Fixer
echo curler......................Starts the Curler
echo webping.....................Starts Website Pinger
echo.
pause
goto prompt
:calc
start calc.exe
:retaskbar
start retaskbar.exe
:curler
start curler.exe
:webping
start webping.exe
I'm planning to turn this into a single exe file for more convenience.
This question already has answers here:
How can I run cmd from batch file and add text to line without executing?
(4 answers)
Closed 4 years ago.
I want to open a cmd shell and set some command in the promt without executing them. The goal is: Shell opens with command (e.g. echo hello) and the user only need to press enter instead of typing it.
Is this possible? I found the /k switch like cmd /k echo hello but this executes the command immediately. The only workaround I see is something like cmd /k "pause && echo hello" but this is not very transparent as the user doesn't know what got executed.
So there are 2 ways of doing this:
Create a shortcut.
Right click in a folder where you want to store the shortcut
Select new Shortcut
In the command window, type the following:
cmd /k echo press Enter to continue ping localhost command && pause >nul && ping localhost
Click next and give it a name and save.
Now you can double click the file and it will print to screen:
press Enter to continue ping localhost command
when Enter is pressed, it will ping localhost
Batch File
Open notepad.exe
Type the following
#echo off
echo press Enter to continue ping localhost command
pause >nul
ping localhost
pause
Save the file to the desired location and give it a .cmd extension
Now you can double click the file and it will do the same as the previously created shortcut version.
As for transparency, if you want the use to see what will be running, you would need to show the user by echoing what will be done.. See the following example.
#echo off
echo echo hello
pause >nul
echo hello
echo ping localhost
pause >nul
ping localhost
pause..
this only duplicates the actual commands as echo commands, hiding the actual command as well as the pause.
Similarly with the shortcut version:
cmd /k echo echo hello && pause >nul && echo hello && echo ping localhost && pause >nul && ping localhost
I want to make file.bat that should run my jar only when user press enter.
Bat must run and does't execute anything without user press enter.
In cmd should be printed:
java -jar crawler-1.0.jar
A part from that user could change this.text
How can I do this?
Excuse me. I think that the real goal of this question is: "How to prefill the cmd.exe command-line input with an editable string", so the user may just press Enter key to execute the prefilled input, or edit it in any desired way. I copied the method below from this post:
#if (#CodeSection == #Batch) #then
#echo off
rem Enter the prefill value in the keyboard buffer
CScript //nologo //E:JScript "%~F0" "java -jar crawler-1.0.jar"
goto :EOF
#end
WScript.CreateObject("WScript.Shell").SendKeys(WScript.Arguments(0));
Try this:
#echo off
Echo java -jar crawler-1.0.jar
set /p =
java -jar crawler-1.0.jar
Echo.
pause
That way, the program will start only if the user hits enter (and not any other key). Also, the window should remain to show the output from the program.
You can always just echo the command, then pause before running the command, not perfect, but it works:
ECHO java -jar crawler-1.0.jar
pause
java -jar crawler-1.0.jar
#echo off
cls
echo java -jar crawler-1.0.jar
echo Press ENTER to continue
pause > nul
<insert command to execute here after user press a button>
line = standard start of batch-file
line = clears the screen so that only your wanted text will appear
line = displays the text you wanted
line = tells the user what to do (it will actually activate regardless of key entered; you can't choose that) [optional of course]
line = regular pause command - > nul does only hide the "press a key" in favour of your 4th line custom message, or no message at all
line = enter your desired run code
I can't comment, so answer to comment question is here:
#echo off
:start
cls
echo java -jar crawler-1.0.jar
echo Press ENTER to continue
pause > nul
<insert command to execute here after user press a button>
goto start
I made a simple batch chat that write the message to an txt file.
I need help with print the file every time it changed and with hidding output.
I used the type, delay and cls to print the file but it didnt work, it didnt printed the file.
launcher.bat:
start cmd /k
call room.bat
call chat.bat
using the launcher photo
room.bat(the problem):
:chat1
cls
TYPE room.txt
timeout /t 0.5
goto chat1
chat.bat(working but show extra info about the os and the file):
#echo off
cls
set D=%Date%
cls
echo enter your name
SET /P name=[name]
pause
:room
cls
SET /P chatpublic=[everyone]
SET "
echo %name%: %chatpublic% |%D%|>> room.txt
pause
goto room
without the launcher photo
Here's the culprit:
echo %name%: %chatpublic% |%D%|>> room.txt
That's because the | vertical line has a special meaning in Windows command line interpreter: commandA | commandB: pipe the output from commandA into commandB.
If you do want use a | vertical line in another sense (e.g. display it with an echo command), then you should escape it as follows:
echo %name%: %chatpublic% ^|%D%^|>> room.txt
I have a simple batch file:
ECHO OFF
CLS
ECHO WELCOME
ECHO.
ECHO Launching your app...
What I would like is to return to a default CMD state where the user can type commands, I mean, this state: C:[path][path].....>
I want to give to the user the possibility to continue to type anything he wants after the echo "Launching your app..."
So visually it would give this:
WELCOME
Launching your app...
C:[path][path][path]> _
#echo off
rem check if started from own process (use our own parameter)
rem and if not, spawn a new cmd with correct parameters and
rem keep it open
if not "%~1"=="__startcmd__" (
"%comspec%" /k "%~f0" __startcmd__ %*
exit
)
rem eliminate custom parameter of parameter list
shift
rem your custom screen
cls
title "command window"
prompt $p$g
echo WELCOME
echo Launching your app ...