Eg1.
@echo off
Dir c \ > A.txt
Call C:\b.bat
echo Hello
Pause
REM NOTE 1
:: NOTE 2
CD \
%[1-9]//parameters
EG2.
@echo off
CHOICE/C dme/m "Defrag,mem,end"
if errorlevel 3 goto end
if errorlevel 2 goto MEM
if errorlevel 1 goto defrag
:d Efrag
: Mem
: End
echo Good bye
Eg3.
@echo off
Set _interval = 5
Set _processname = WinRAR
Set _processcmd = C:\a.zip
Set _processtimeout = 10
Set _username = Administrator
: Loop
set/a isAlive = False
Tasklist/fi "username eq%_username%" | FIND/C "%_processname%" > Tmp.txt
set/p num = <tmp.txt
del/f Tmp.txt
If "%num%" = = "0" (
Start%_processcmd% | echo Start%_processname% on%time%
CHOICE/D y/t%_processtimeout% > Null
)
If "%num%" NEQ "0" Echo has started
CHOICE/D y/t%_interval% > Null
Goto Loop
***********************************
1. See if a port is occupied by that process
Netstat-ano | Find "8888"
tasklist | Find "pid"
Taskkill
2. Escape character ^
Echo ABC^>CBA
3. List of common commands
Cd |
Switch directories |
Copy |
Copying files |
Del |
deleting files |
deltree |
Delete a directory tree |
Dir |
View Catalog Contents |
diskcopy |
Disk Copy |
Format |
Format disk |
Md |
Create a Directory |
Type |
Show file contents |
Rd |
Delete Directory |
ren |
Renaming |
Cls |
Clear Screen |
Move |
Moving files |
Xcopy |
Copy Files directory |
Help |
Help for the command you are using |
|
|
Getting Started with Windows batch