omnix
omnix

Reputation: 1899

How to make CMD say something?

I need to create a .cmd file, and when I execute it, opens up cmd and then shows whatever I typed in the file. Like

(Of course this is fake)

Scanning.....c:/windows Scanning.....c:/ Scanning.....Ports

etc,so it says whatever I want.

Also, is there a way to have a interval of when it says something?

Like:

Scanning..... (5secs after) Scanning....

Is this possible? If so, how?

Upvotes: 1

Views: 40453

Answers (5)

Student Seng
Student Seng

Reputation: 113

Ok, to create a .cmd/.bat file(AKA Batch file) to say something

We use echo and the syntax is echo YOURTEXTAbd if you want to have spaces in between: echo"YOUR TEXT" as simple as that. And to add a blank line:echo. (Yup, add the dot without space)

Now for the delay I recommend the timeout command, and the syntax is: timeout /t "your time in seconds without quotation marks" There are also some additional options you can add: If you don't want the command to display the text "Waiting for * seconds, press a key to continue" then add >nul at the end if all options. And if you don't want to allow someone to press any key to continue, use the option /nobreak after /t and before >nul if you're using >nul

And now for more stuff

You can change the title of the file by using title, the syntax is title "Titile you want to change to with quotations if you want spaces"

You can also actually change the foreground and background colour , for instructions, type color/? into Command Prompt

You can actually don't let the batch file display "C:\Users\Yourname>" or anything like that infront of any command by using @echo off at the first sentence in the whole batch file.

And you can also use pause to pause the file from running any further until any key is pressed. And if you don't want it to display "Press any key to continue" you can also add >nul at the back.

To clear the whole page: cls

Ok, enough said, now here is an example file:

Color 02 Title Windows Scanner Echo. Echo ===================== Echo Windows Scanner Pro Echo v2.0 BETA Echo ===================== Echo. Echo Press any key to start Basic Scan Pause>nul Cls Echo ===================== Echo Windows Scanner Pro Echo v2.0 BETA Echo ===================== Echo. Echo Starting Scan... Timeout /t 5 /nobreak>nul Echo. Echo SCAN STARTED Timeout /t 8 /nobreak>nul Echo ... Timeout /t 3 /nobreak>nul Echo ... Timeout /t 6/nobreak>nul Cls Echo ===================== Echo Windows Scanner Pro Echo v2.0 BETA Echo ===================== Echo. Echo SCAN RESULTS: Echo Nothing found Echo. Pause Echo THANKS FOR USING OUR SERVICE Echo. Pause Cls Echo ==================== Echo Windows Scanner Pro Echo v2.0 BETA Echo ===================== Echo. Echo Bye! Echo. Echo Press any key to exit Pause>nul Exit

That's just an example(And is not a real scan), you can edit and do more stuff with it, you can even ask the user to input the type of scan they want! ( Search google it ask it again or contact me)

Upvotes: 2

syss
syss

Reputation: 231

If you want to have a spinning bar you can also take the script from my site here

as this link appears down here is what you can do. Please see the link (if it gets online ever again) what it is about the backline. (it contains 79 0x09 characters which could not be typed in by an ordinary notepad)

    @echo off

:Scan
echo Start Scan
scan.exe parameter
:Scanloop
tasklist | find>nul "PING.EXE" & call :Spinner Scanning... || goto:end
goto Scanloop

:end
cls
echo This is the end
pause>nul

rem ***************************************
rem * Spinner
rem ***************************************
:Spinner
set backline=
<nul (set/p z=[\] %*)
<nul (set/p z=%backline%)
ping>nul localhost -n 1
<nul (set/p z=[^|] %*)
<nul (set/p z=%backline%)
ping>nul localhost -n 1
<nul (set/p z=[/] %*)
<nul (set/p z=%backline%)
ping>nul localhost -n 1
<nul (set/p z=[-] %*)
<nul (set/p z=%backline%)
ping>nul localhost -n 1
goto :EOF

This would be the script.

ping>nul -n 2 localhost

waits ca. 1 second and

ping>nul -n 3 localhost

waits ca 2 seconds. It is not as precise as sleep, but takes less ressources.

Upvotes: 0

codingbadger
codingbadger

Reputation: 43984

Another option is to ping the localhost for 20 seconds:

@echo Off
@echo "Scanning.... C:\Windows"   
ping 127.0.0.1 -n 20 > nul
@echo "Scanning.... Ports"

pause

Upvotes: 2

DGH
DGH

Reputation: 11539

echo textGoesHere

or

echo "Hey look, text"

will output the text.

pause

will wait for the user to press a key and prompt with "press any key to continue".

sleep 5

will pause for 5 seconds.

However, as of Windows Vista, sleep seems to no longer be included in the default set of commands. Supposedly this: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en contains the sleep.exe file you'd need to do this.

Upvotes: 2

Vladimir Ivanov
Vladimir Ivanov

Reputation: 43098

use echo command.

For delaying:

failed to test but try to use sleep command.

Upvotes: 1

Related Questions