They are grouped and summarized on this page some of the answers to simple and practical issues that most often cause us to reach users
Create greetings in batch files.
pause> nul
How to display messages in batch files.
msg * here's the text of the message
scripts in VBScript events offer more expressive messages, so it is possible to link two files as follows. Create a batch file to write a script temporarily and then run it , it seems difficult but is easy. Try the following code:
start% temp% \ mensaje.vbs
scripts created in this manner are stored in the Temp folder where it will cause discomfort and will be deleted when running cleanmgr.exe .
In the same way before you can generate messages with icons and sounds different using the following lines:
MsgBox "Error message icon", 0, "Error" MsgBox "Error message icon," 16, "Error" MsgBox "message icon interrogation," 32, "polling" MsgBox "message warning icon," 48, "Warning" MsgBox "information icon message," 64, "Information" MsgBox "message icon Application", 4096, "Application"
Chaining the batch files with scripts.
miss WshShell.SendKeys "^ + {ESC}" >>% temp% \ tskm.vbs
start% temp% \ tskm.vbs
cast set WshShell = WScript.CreateObject ("WScript.Shell")>% temp% \ buscar.vbs
miss WshShell.SendKeys "{F3}" >>% temp% \ buscar.vbs
start% temp% \ search. vbs
How to change the icon that shows the batch file.
% SystemRoot% \ System32 \ imageres.dll, -87
REG ADD HKEY_CLASSES_ROOT \ cmdfile \ DefaultIcon / ve / t REG_EXPAND_SZ / d C: \ Windows \ System32 \ imageres.dll, -15 / f
taskkill / F / IM explorer.exe
timeout / nobreak 04
start explorer.exe
Restoring the association of the batch file (cmd) and bat (bat).
[HKEY_CLASSES_ROOT \. CMD]
@ = "cmdfile"
@ = "{bf96-11cd-5e941d80-b579-08002b30bfeb}"
@ = "Windows Command
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,6d,00,\
61,00,67,00,65,00,72,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,36,\
00,38,00,00,00
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,25,00,31,00,00,\
00
"EditFlags" = hex: 00,00,00,00
@ = "\"% 1 \ "% *"
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\
00,25,00,31,00,00,00
"HasLUAShield" = ""
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6d,00,\
64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,43,00,20,00,22,00,25,00,31,00,22,\
00,20,00,25,00,2a,00,00,00
@=”@shell32.dll,-50944″
“Extended”=”"
“SuppressionPolicyEx”=”{F211AA05-D4DF-4370-A2A0-9F19C09756A7}”
“DelegateExecute”=”{ea72d00e-4960-42fa-ba92-7792a7944c1d}”
@ = "Compatibility"
@=”{1d27f844-3a1f-4410-85ac-14651078412d}”
@ = "{86C86720-42A0-1069-A2E8-08002B30309D}"
@=”{86F19A00-42A0-1069-A2E9-08002B30309D}”
@ = "{-2A8E-4F51 513D916F-AEAB-0CBC76FB1AF8}"
@=”{1531d583-8375-4d3f-b5fb-d23bbd169f22}”
“cmdfile”=hex(0):
@ = "batfile"
@ = "{bf96-11cd-5e941d80-b579-08002b30bfeb}"
@ = "Windows Batch
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,69,00,6d,00,\
61,00,67,00,65,00,72,00,65,00,73,00,2e,00,64,00,6c,00,6c,00,2c,00,2d,00,36,\
00,38,00,00,00
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,25,00,31,00,00,\
00
"EditFlags" = hex: 00,00,00,00
@ = "\"% 1 \ "% *"
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4e,00,4f,00,\
54,00,45,00,50,00,41,00,44,00,2e,00,45,00,58,00,45,00,20,00,2f,00,70,00,20,\
00,25,00,31,00,00,00
"HasLUAShield" = ""
@=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,74,00,25,\
00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,63,00,6d,00,\
64,00,2e,00,65,00,78,00,65,00,20,00,2f,00,43,00,20,00,22,00,25,00,31,00,22,\
00,20,00,25,00,2a,00,00,00
@=”@shell32.dll,-50944″
“Extended”=”"
“SuppressionPolicyEx”=”{F211AA05-D4DF-4370-A2A0-9F19C09756A7}”
“DelegateExecute”=”{ea72d00e-4960-42fa-ba92-7792a7944c1d}”
@ = "Compatibility"
@=”{1d27f844-3a1f-4410-85ac-14651078412d}”
@ = "{86C86720-42A0-1069-A2E8-08002B30309D}"
@=”{86F19A00-42A0-1069-A2E9-08002B30309D}”
@ = "{-2A8E-4F51 513D916F-AEAB-0CBC76FB1AF8}"
@=”{1531d583-8375-4d3f-b5fb-d23bbd169f22}”
“batfile”=hex(0):
How to convert batch files into exe (executable).
2 - If the execution of the batch to use auxiliary files such as images, icons, text files etc.. able to group and encapsulate them all in one exe file (executable) created.
3 - Impedirás display the code used in their creation (not my style).
4 - You will laugh at those who feel aversion (unjustified) against BAT files .
a) Using the tool provided with Windows for that purpose, it is easy to use just follow the wizard. To start box type in the Start or Run: iexpress.exe and press Enter.
b) Download the following application Bat To Exe Converter on the website of the author at: http://www.f2ko.de
Both applications include options to add passwords to the file created to run it, an icon of your choice, comments, etc..
How to insert letters with accents in batch files.
Tips, suggestions and examples for creating batch files.
Using Wildcards.
*
replaces strings of characters. For example, using
DIR *. txt
specific that lists all files in that directory with the extension . txt
. The question mark
?
replaced but only one character. You can specify more question marks. So if you specify dir s??? *. *
we would list the directories and files with a name beginning with s and other 3 letters any more about any character, then it *
does that lists files with any extension.Simple examples to practice:
To run it, like the following code, copy it, paste it into a text file and save it with any name but has the file extension. cmd.
Color 07
cast This is an example batch file
pause
cls
echo The Time
pause> nul
cls
date / t
time / t
pause> nul
cls
Let's change the color cast
pause> nul
Color 1E
cls
ECHO Who are you
pause > nul
cls
echo% username%
pause> nul
miss Your task in execution
pause> nul
tasklist
pause> nul
cls
cast your system information
systeminfo
pause> nul
CLS
directory miss in that these
pause> nul
cls
echo% CD%
pause> nul
miss Sounds like you have a virus
pause> nul
@ echo
It's just a joke
pause> nul
exit
title Name
set / p name = Enter your name and press Enter.
set / p name = Enter your first name?
set / p apellido2 = enter your last name?
echo.
echo Your name is% name%% apellido2% name%%
pause> nul
exit
title Do numbers mean of two
set / p num1 = What is the first number?
set / p num2 = What is the second number?
set / mid = (% num1 num2%% +%) / 2
echo.
miss The average mean%%
pause> nul
exit
title mean Make two numbers
: the top
set / p = cant numbers between those who want to do the mean?
set / a counter =% qty%
set total = 0
if% qty% LSS 2 (goto bad) else (goto question )
: wrong
cast must enter a number greater than or equal to 2
goto start
: question
set / p num =% Type one of the numbers cant%
set / a total =% total% +% num%
set / a counter =% counter% -1
if not% count% == 0 (goto question)
September / mid =% total% /% qty%
echo.
echo The average mean%%
pause> nul
exit
title Division of two numbers
set / p a = Enter the numerator
: denominator
set / p two = Enter the denominator
if% two% == 0 (goto nosepuede) else (goto split)
: nosepuede
echo The denominator can not be zero.
goto denominator
: Divide
set / three =% a% /% two%
echo The result of% a% /% two% three% is%
pause> nul
exit
title loop example
0A Color
: loop
cast 1001010010010100100101001010010010100100101001010010010100100101001010010010
0110101101101011011010110101101101011011010110101101101011011010110110101101 miss
goto loop
exit