Windows
打开windows中特定程序
win + R > cmd > Enter
win + R > devmgmt.msc > Enter
win + R > services.msc > Enter
基础命令
help-查看某个命令帮助信息
help dir
cls-清屏
cls
dir-查看目录下的文件及文件夹
dir
mkdir-创建目录
mkdir test
mkdir test\test\test
rmdir-删除目录
rmdir /s/q test
cd-切换路径
cd /
cd ../
D:
cd.>a.txt
新建文件
cd.>a.txt
echo a >> a.txt
del-删除文件
del /q a.txt
move-移动文件
move a.txt test3
move test2 test3
copy-复制文件
copy a.txt test\b.txt
copy con t.txt
xcopy-复制文件夹或文件
xcopy /y a.txt test
xcopy /y/e test4 test5\
rename-重命名文件或文件夹
rename a.txt b.txt
rename test test2
title-设置 cmd title
title java-1.8
start-启动单独的窗口运行命令。
start [title] [/b] [/d path] a.bat
start "title" /b /d "D:\test" a.bat
call-从批处理程序调用另一个批处理程序
call run.bat
chcp查看 dos 窗口字符集
chcp 65001
chcp 936
mklink-创建符号链接。快捷方式
mklink /j "test" "E:/a"
<,>,<<,>>-输入输出重定向
echo 11 > test.txt
echo 11 >> test.txt
cmd
cmd /c dir
cmd /k dir
cmd /c start dir
cmd /k start dir
bat 预定义变量
给bat文件传参
a.bat 11 22
扩展变量和bat 所在路径有关
%0%
%~dp0%
%~nx0%
%~n0%
%~x0%
变量内容截取
%VAR:str1=str2%
%VAR:~start,count%
set a=abcdef
set b=%a:~2,4%
set设置和查看环境变量
set a = C:\WINDOWS
cd %a%
set PATH=%PATH%;D:\test\bin
set /a var=2-1
bat编写
基础语法
rem
echo
if
for
goto
pause
if
@echo off
chcp 65001
set num1=100
set num2=101
set num3=100
set str1=str11
set str2=str12
set str2=str11
if %num1%==%num3% (
echo num1等于num3
)else (
echo num1不等于num3
)
if %num2% gtr %num3% (
echo num1大于num3
)else (
echo num1不大于num3
)
if not defined num (
echo 未定义变量 num
)
pause
for
@echo off
chcp 65001
for %%a in (aa,bb,cc) do (echo %%a)
pause
goto
@echo off
chcp 65001
set num1=100
set num3=100
if %num1%==%num3% (goto eq)
echo 执行eq之后执行
pause
:eq
echo 11
echo 12
pause
sc创建、删除、启动、关闭服务
sc create serviceName
sc delete serviceName
sc start serviceName
sc stop serviceName
sc query serviceName
sc create testService binPath= "D:\nginx-1.14.2\nginx.exe" type= share start= auto DisplayName= "testServiceDisplay"
SC QUERY %MYSQL_SERVICE_NAME% > NUL
IF ERRORLEVEL 1060 (
echo 服务:%MYSQL_SERVICE_NAME% 不存在,安装此服务
)
查看端口占用
netstat -ano | findstr "端口号"
根据Pid查看进程
tasklist | findstr "Pid"
杀死进程
taskkill -f -im java.exe
查看TCP/IP配置
ipconfig
ping检测网络是否通畅
ping www.baidu.com
ping 192.168.202.20
net
net start serviceName
net stop serviceName
net time