当前位置:网站首页>[batch dos-cmd command - summary and summary] - application startup and call, service and process operation commands (start, call, and)
[batch dos-cmd command - summary and summary] - application startup and call, service and process operation commands (start, call, and)
2022-06-25 07:31:00 【dssgresadfsrgre】
One 、 Program startup command ——start
start Command is usually used to open a file ( It is usually an executable program ) Or folder .
First use start /? Command for general help information .

(1) Open a folder .start dir, This dir It can be the root directory of the disk , It can also be a subdirectory on the disk . If not min or max Parameters , It will be maximized by default ( Open at the front desk ).
If you want to open e Packing list , Carry out orders 【start e:】.

If you want to open e A folder under the root directory ( for example adobe), Carry out orders 【start e:\adobe】

(2) Open a file . start path, This path It can be a document type txt、doc、excel file , It can also be multimedia mp3、mp4 file , It can also be executable exe、bat file .
Try opening it exe file ,【start D:\ Summary of green installation free small software \PdgCntEditor_PDF Directory editor \PdgCntEditor.exe】.
Successfully opened .

(3) Whether it's opening a file , Or open the folder , Pay attention to the problem of spaces .
What do you mean ? What do you mean by paying attention to blank space ?
cmd Spaces are often used to distinguish between different parameters in the window , If you use a space, it often means that the next parameter is after the space or the value of the parameter before the space is given .
For example, the path of cool dog music is 【D:\Program Files (x86)\KuGou\KGMusic\KuGou.exe】, Then we execute the order 【start D:\Program Files (x86)\KuGou\KGMusic\KuGou.exe】, You'll find something wrong . Prompt file not found ( clip )【D:\Program】, It's easy to know cmd The program separates the path string before and after the space , How can we solve this problem ?

The solution is simple , Which level directory has a space in its name , Just put double quotation marks there . Carry out orders 【start D:\"Program Files (x86)"\KuGou\KGMusic\KuGou.exe】.

Note that the command is not executed 【start "D:\Program Files (x86)\KuGou\KGMusic\KuGou.exe"】 , I don't know why , Visually reflect , Will reopen a cmd window , Working directory unchanged .
If there are multiple spaces on the full path , It is obviously troublesome to add double quotation marks to each level .
In fact, we have another way .
Suppose you want to open a folder 【D:\BaiduNetdiskDownload\test1 2 3\test 3 4 5】, Carry out orders 【start "" "D:\BaiduNetdiskDownload\test1 2 3\test 3 4 5"】( Fill in the first double quotation mark ).

(4) If you do not want the window to appear on the screen immediately after executing the command , That is, you want to open it in the background , It can be used /min Parameters .
For example, open a exe Program , Carry out orders 【start /min D:\ Summary of green installation free small software \PdgCntEditor_PDF Directory editor \PdgCntEditor.exe】

Sure enough, it was opened in the backstage .
But I still found some programs , Even if you add /min Parameters ,
Can't open in the background , Like cool dog music .
Two 、 Program call command ——call
Call The purpose of the command is to call what has been written bat file , Suppose it is called bat File name is 【demo.bat】, Actively invoked bat The file name is 【main.bat】, So in main.bat Call in demo.bat It needs to be used call command .
similar C Function declaration in language , Function defined in demo.bat In the middle of , The function is declared in the main program file main.bat In the middle of .
Print first call Command help information .

Let's see how to use it call This command .
Create a new one demo.bat file , The code inside is .
@echo off
echo Now start executing the subroutine
echo You can count to 10 Do you ?
echo I can't help it ! 1,2,3,4,5,6,7,8,9,10
echo That's great
echo I wish you happiness
echo See the ghost
echo Why didn't you do anything later
echo See the ghost
echo Go on ?Let's create another one main.bat file , The code inside is .
chcp 65001
@echo off
echo Hey, Lao tie has got it ! The main program starts to run ...
echo Can you count ?
echo I'm not going to , But my son will , You ask him .
call D:\D-desktop\demo.bat
echo The main program is over , Have a good rest .
pauseVisible direct use 【call path】 You can successfully call .
But I still found some problems during the experiment .
The first question is : Suppose the last line of the subroutine file has pause, Will bring you closer pause The end of a period in a few lines of 、 Or the line at the end of the question mark should be treated as an order , It turns out to be wrong .
For example demo.bat File modification , and main.bat The document remains the same .
@echo off
echo Now start executing the subroutine
echo You can count to 10 Do you ?
echo I can't help it ! 1,2,3,4,5,6,7,8,9,10
echo That's great
echo I wish you happiness .
echo See the ghost .
echo Why didn't you do anything later .
echo See the ghost .
echo Go on ?
pauseAfter execution pause Before 4 There are problems in all the lines .

The second question is : Suppose I remove the last line of the subroutine file pause, Then, the last few lines of commands will fail .
Same will demo.bat The document is modified , then main.bat remain unchanged .
@echo off
echo Now start executing the subroutine
echo You can count to 10 Do you ?
echo I can't help it !1,2,3,4,5,6,7,8,9,10
echo That's great
echo I wish you happiness
echo See the ghost
echo Why didn't you do anything later
echo See the ghost
echo Go on The execution result is shown in the figure below , Last 4 OK, and the whole army was destroyed . Don't think it's just the end 4 That's why things go wrong , You can try it yourself , A lot of bug, Therefore, it is recommended to use this function with caution , You can put the code in the main program .

3、 ... and 、 process / Service operation ——tasklist、net
3.1 Process management
- Displays the currently running process :
tasklist - Run a program or command :
start The program name - The end of the process , By name :
taskkill /im notepad.exe( Close Notepad ) - The end of the process , Press PID:
taskkill /pid 1234( close PID by 1234 The process of )
3.2 Service management
- Displays the currently running services :
net start - Start the specified service :
net start service name - Stop the specified service :
net stop service name
边栏推荐
- 正版photoshop2022购买体验经历分享
- Several schemes of traffic exposure in kubernetes cluster
- 用太极拳讲分布式理论,真舒服!
- [Introduction aux uvm== > Episode 9] ~ modèle de registre, intégration du modèle de registre, méthode conventionnelle du modèle de registre, scénario d'application du modèle de registre
- 高考志愿填报,为啥专业最后考虑?
- Operate cnblogs metaweblog API
- 【批处理DOS-CMD命令-汇总和小结】-cmd扩展命令、扩展功能(cmd /e:on、cmd /e:off)
- Kube scheduler source code analysis (1) - initialization and startup analysis
- Clearing Magento log data - clearing Magento log data
- We are different
猜你喜欢

In depth analysis of Apache bookkeeper series: Part 3 - reading principle
![[pytest] modify the logo and parameterization in the allure Report](/img/c0/93519da008ec137c447bb11aa7b73e.png)
[pytest] modify the logo and parameterization in the allure Report

13 `bs_ duixiang. Tag tag ` get a tag object

基于 KubeSphere 的分级管理实践

【工具分享】一款颜值与技能并重的软件

终于等到你,小程序开源啦~

Ppt template of small fresh open class education courseware

MCU IO explanation (pull-up pull-down quasi bidirectional input / output push-pull open drain)

赚够钱回老家吗

【UVM入門 ===> Episode_9 】~ 寄存器模型、寄存器模型的集成、寄存器模型的常規方法、寄存器模型的應用場景
随机推荐
终于等到你,小程序开源啦~
分布式锁中的王者方案 - Redisson
Is it possible to use Jasmine's toHaveBeenCalledWith matcher with a regular expression?
高效探索|ES地理位置查询的一次应用实践
The e-book "action guide for large organizations to further promote zero code application platform" was officially released!
[pytest] modify the logo and parameterization in the allure Report
Harmony美食菜单界面
Clearing Magento log data - clearing Magento log data
Shell命令学习
Conditional grouping with $exists inside $cond
The perfect presentation of Dao in the metauniverse, and platofarm creates a farm themed metauniverse
破万,我用了六年!
Finally, when you open source the applet ~
I have used it for six years!
Omni toolbox direct download
正版photoshop2022购买体验经历分享
Kubernetes 集群中流量暴露的几种方案
[Yu Yue education] engineering testing technology reference of Wenhua University
How comfortable it is to use Taijiquan to talk about distributed theory!
Tempest HDMI leak receive 1