<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">clear_root.bat</span>
windows cd 跳转:http://blog.sina.com.cn/s/blog_67998bf40100kay1.html
1.跳转到当前驱动器的根目录
cd [当前驱动器盘符]:\ 例如: cd c:\
或者更简单的 cd\
2.跳转到当前驱动器的其他文件夹
以C盘下的WINDOWS文件夹为例 输入:cd C:\WINDOWS
3.跳转到其他驱动器
以从C盘跳转到D盘为例 在任意目录下直接输入: D:
4.跳转到其他驱动器的其他文件夹
假设当前在C盘,要跳转到E的software目录 cd /d e:\software
注意此处必须加/d参数。否则无法跳转。
5.跳转到上一层目录
cd..
cd !_stock_impulse_direct_selling
call clear.bat
cd ..
cd !_stock_impulse_limit_price_buy
call clear.bat
clear.bat
rd /q /s ipch
rd /q /s stock_impulse\Debug
rd /q /s stock_impulse\Release
rd /q /s stock_impulse\ipch
del stock_impulse\*.con
del *.sdf /f /q
del Debug\*.pdb /f /q
del Debug\*.ilk /f /q
del Debug\*.exe /f /q
del Debug\*.con /f /q
del Release\*.pdb /f /q
del Release\*.ilk /f /q
del Release\*.exe /f /q
del Release\*.con /f /q
clear best:
pushd ..\Tutorials
横向遍历:方便控制可以知道的文件夹跟文件
FOR /D %%f IN ("*.") DO RMDIR /S /Q %%f\Debug
FOR /D %%f IN ("*.") DO DEL /Q %%f\"*.sdf"
递归遍历:
for /R %%i in (.) DO RD %%i
for /R %%i in (ss) DO RD %%i
for /R %%i in (*.txt) DO ECHO %%i
FOR /f %%i in ('dir /ad /b /s') DO echo %%i
popd
除了for之外遍历文件夹跟子文件夹的方法还有dir命令
参考:http://www.cnblogs.com/adforce/p/3282591.html
del高级点的操作,删除当前文件下小于3K的所有文件
attrib +s "%~f0"
for /r %%a in (*) do (
if %%~za lss 2300 del "%%a"
)
%cd% %~dp0
这两个变量都是用来表示当前目录,可使用时却大不相同,记录下
%cd%代表的是执行文件的当前目录,强调bat是在哪里启动的;->盘符展开后是可改变的
%~dp0代表的是bat文件所在的文件目录,强调bat的文件位置 ->盘符展开后是不可改变的
参考:http://www.cnblogs.com/cheng07045406/p/3714288.html
at
at
::at 11:14 msg * tip
::at 11:16 msg yanglu tip
::at 8:00 /every:M,T,W,TH,F,S,Su cmd /c d:/auto/autobackup.bat
::at /del /yes
::at 11:40 start "C:\\bat\bat.bat"
:: sc query schedule | find "STOPPED" && sc start schedule
::at 12:33 F:\Debug\test_at_cmd.exe
at 13:25 cmd /c F:\test.bat
at <span style="font-family: Arial, Helvetica, sans-serif;">15:25 /every:M,T,W,TH,F cmd /c </span><span style="font-family: Arial, Helvetica, sans-serif;">F:\yanglu_projects\all_release_version\Release_get_day_profit\start.bat</span>
Pause
refence:http://support.microsoft.com/kb/313565/zh-cn
shutdown /f /s /t 0
start深究:
start是在一个新的窗口中启动程序,一个bat里面多个start的时候会并发执行启动多个cmd窗口,用/w参数可以让其按照顺序执行
而写程序名字多行,是在一个cmd窗口分别按照顺序一个一个执行
01: 只写程序名会在一个窗口中顺序执行,第二个程序要等第一程序结束
moving_average.exe
moving_average_slope.exe
moving_average_slope_break_through.exe
ping -n 1 127.0.0.1 > nul
move /y *.csv doc\
02:在多个窗口中执行,是按照顺序的
start /w moving_average.exe
start /w moving_average_slope.exe
start /w moving_average_slope_break_through.exe
ping -n 1 127.0.0.1 > nul
move /y *.csv doc\
03:在多个cmd窗口中并发一块执行
start moving_average.exe
start moving_average_slope.exe
start moving_average_slope_break_through.exe
ping -n 1 127.0.0.1 > nul
move /y *.csv doc\
start "" "D:\Debug\test.exe"
<pre code_snippet_id="502011" snippet_file_name="blog_20141119_12_993823" name="code" class="cpp">start "" "D:\Release\test.exe"
call命令调用另一个批处理或者程序等等调用返回后继续执行原来的批处理命令,call 参数可以传入或传回,start更多的传入参数,不能传回参数
全自动启动关闭程序所需材料:
::ntsd -c q -pn explorer.exe
::taskkill /f /im Explorer.exe
at 9:30 /every:M,T,W,TH,F D:\trusteeship\op_cp_hash_buy_best\op_cp_hash_buy_best.exe
at 9:30 /every:M,T,W,TH,F D:\trusteeship\options_buy_lowest\stock_options_buy_all_lowest.exe
at 11:29 /every:M,T,W,TH,F taskkill /F /im "op_cp_hash_buy_best.exe"
at 11:29 /every:M,T,W,TH,F taskkill /F /im "stock_options_buy_all_lowest.exe"
at 13:00 /every:M,T,W,TH,F D:\trusteeship\op_cp_hash_buy_best\op_cp_hash_buy_best.exe
at 13:00 /every:M,T,W,TH,F D:\trusteeship\options_buy_lowest\stock_options_buy_all_lowest.exe
at 14:59 /every:M,T,W,TH,F taskkill /F /im "op_cp_hash_buy_best.exe"
at 14:59 /every:M,T,W,TH,F taskkill /F /im "stock_options_buy_all_lowest.exe"
::at /del /yes