Batchfiles Commands

Wok247

Well-Known Member
OP
Newcomer
Joined
Dec 7, 2008
Messages
74
Trophies
0
Location
In font of my computer
Website
Visit site
XP
-9
Country
United States
1.How to make a Batch file (.bat file).
lecture.gif


a.First open Notepad or use option b.

b.1.Go to Start
b.2.Start Run...
b.3.Give in "notepad" without the ".

2.Then use the commands that you can find in this Blog.

3.Use file "Save As".

4.You have to change "Save as type "Text Documents (*.txt)" to "All Files".

5.Now give the "File name" in for example batch.bat and always say .bat on the end!!

6.Now save and you have your Batch file (.bat)


Commands with discribtion:

@echo off = Put this on the top of a .bat and it won't show all the pads it use example: C:\Program Files\Internet Explorer
echo = Write "echo Hello World" and on the screen apeers "Hello World"
echo. = Make a clear line on the screen.
DATE = Show or set date.
DATE /T = Only show date
TIME /T = Only time
TIME = Show or set time
pause = Pause it sayes " Press any key to continue..."
cls = Clear screen
exit = Exit the .bat file
del. =WARNING do not use this command it will clear your COMPLETE Hard drive!!
del "C:\Program Files\Internet Explorer" = it will delete the map/file
call = Start another .bat in your .bat file
start calc = The .bat will start calculator i use this a an example you can use notepad or other progr.
goto = goto says goto ... example goto 1 then he goes to :1
shutdown -s -t 7 = The computer will shutdown himself in 7 sec without saving anything. 7 stands for 7 sec.
dir = Displays files in a directory.
mkdir = Makes a directory
dir >> a.txt outputs the result of the command to a text file.
rename = Renames a file, remember to use " when spaces are in the name/location.
help (command name) =Gives you info about command (works fine in cmd.exe)


:Colors

Color [attr]
attr Specifies color tribute of console output

Color attributea are specified by TWO hex digits -- the first
correspondds to the background; the second the foreground. Each digit
can be any of the following values:

0 =Black 8 =Gray
1 =Blue 9 =Light Blue
2 =Green A =Light Green
3 =Aqua B =Light Aqua
4 =Red C =Light Red
5 =Purple D =Light Purple
6 =Yellow E =Light Yellow
7 =White F =Bright White







shutdown commands:

first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to

example: SHUTDOWN -s

:PING = Test a network connection - if successful, ping returns the ip address.

Code: PING [options] destination_host

-w timeout Timeout in milliseconds to wait for each reply.
-i TTL Time To Live.
-v TOS Type Of Service.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-t Ping the destination host until interrupted.
-l size Send buffer size.
-f Set Don't Fragment flag in packet.
-r count Record route for count hops.
-s count Timestamp for count hops.
-j host_list Loose source route along host_list.
-k host_list Strict source route along host_list.
destination_host The name of the remote host



How to make a menu in xp:

set INPUT=
set /P INPUT=Say yes or no!:

if "%input%" =="yes" goto yes
if "%input%" =="no" goto no

:yes
echo You said yes.
pause

:no
echo You said no.
pause

In The menu you also can use the :
)ELSE(
goto else
Command it says if you give something in like "wtf" it goto :else


If some of you have some command I don't know or wants to correct my add a post/pm me and i will add it to the list!
 

Joey90

Not around any more
Member
Joined
Apr 21, 2007
Messages
703
Trophies
0
Age
32
Location
UK
Website
Visit site
XP
180
Country
Useful, but not sure of the precise syntax required:

FOR %%a in (filename) DO(
command 1
command 2
)
command 3

That will do all the commands listed before the bracket to each file which matches the filename in brackets (* is a wildcard of any length, ? might be a wildcard of 1 character (not sure)) Then follw them by the command after the bracket.

e.g.

MKDIR Converted
FOR %%a in (*.start) DO(
converter.exe %%a
)
MOVE *.finish Converted\

Would first make a directory \Converted\ then it would run converter.exe with all files ending in .start then it would move all files ending in .finish into the \Converted\ directory...


P.S. there are lots of websites detailing .bat commands - and there are a hell of a lot.
 

Maikel Steneker

M3 Fanboy
Member
Joined
May 16, 2007
Messages
3,394
Trophies
1
Age
32
Website
ndss.nl
XP
383
Country
Netherlands
Why would you even want to learn batchfiles? I've been using them for years so I've so much experience with them that they're just the easiest way of doing things for me, but learning a proper language seems a better idea.
 

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,646
Country
France
Good timing, I would need a command in batch file.
I want a "wait" command, to wait a given amount of time.
I don't want the "pause" command.


I would like to run a batch at windows startup, but the command only executed after 5 minutes.
to run another program only after all the others are up and running properly.


I didn't find any delay command in MSdos.
I looked at windows event manager, but it doesn't allow any delay either.
I don't want to install any other software to do it if I can do it with the actual tools.

Thanks
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,284
Country
United Kingdom
@Cyan none that I know of but a workaround comes from "ping" (should be in every version of windows worth your time). Something like
ping 1.1.1.1 -n 1 -w 2000
Run it for usage (n is number of packets to try and w is timeout in milliseconds)

Back on topic good on you Wok247, many people do not know about the command line and batch files and then look at awe when I do a whole bunch of tasks in 10 seconds flat.
Some commands
dir - displays files in a directory.
mkdir - makes a directory
dir >> a.txt outputs the result of the command to a text file.
rename - renames a file, remember to use " when spaces are in the name/location.
Generally many commands have help functions, usually /? or --help or similar will bring it up. Failing that just add a really random command to the end of it and it will say what you need to do to get usage.
 

chuckstudios

Putting the pro in procrastination
Member
Joined
Jul 19, 2006
Messages
890
Trophies
0
Age
124
Location
North Carolina, USA
Website
www.schlarp.com
XP
275
Country
United States
Problematique said:
color c
smile.gif
hahah gets so funny it looks so evil
i know some batch file that shows starwars in text, windows Easter egg

No, it's not an easter egg at all. It opens a connection to a server on the internet that sends your computer those graphics. By your logic, Youtube is also an easter egg.
 

Wek247

New Member
Newbie
Joined
Dec 9, 2008
Messages
0
Trophies
0
XP
0
Country
United States
Hello Wok247 nice topic!
i like the command: "Net user" you can see all accounts with this command
and you can change passwords of users (admins) and delete users and create new
accounts!

:create new account
type in CMD "net user" now you will see a list of all users of the computer
you type "net user (account name) (password) /add

like this: net user wek247 829 /add

:change passwords
typ in CMD net user (account name) *
now you can change the password!
happy.gif
 

Problematique

Banned!
Banned
Joined
Dec 30, 2008
Messages
54
Trophies
0
XP
11
Country
New Zealand
Wek247 said:
Hello Wok247 nice topic!
i like the command: "Net user" you can see all accounts with this command
and you can change passwords of users (admins) and delete users and create new
accounts!

:create new account
type in CMD "net user" now you will see a list of all users of the computer
you type "net user (account name) (password) /add

like this: net user wek247 829 /add

:change passwords
typ in CMD net user (account name) *
now you can change the password!
happy.gif

ehehe i canded the schools admin password with that...good times..good times
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: @salazarcosplay, Morning