Getting Started with Windows batching

Source: Internet
Author: User
Tags clear screen

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.