批处理切换当前目录的做法

作者:朱金灿

来源:http://blog.csdn.net/clever101

    

             很多时候批处理要切换当前工作目录,网上搜了下,可以这样做:

@echo off

rem 输出当前工作目录
echo %cd%

rem 打开当前目录下的1.txt
type 1.txt

rem 设置当前目录为F:\TestProject 
set current_dir=F:\TestProject  

pushd %current_dir%  

rem 输出当前目录为F:\TestProject
echo %cd%

rem 打开F:\TestProject\1.txt
type 1.txt

popd  

pause

参考文献:

 

1. Windows批处理更改当前工作路径



posted on 2013-12-16 16:53  岚之山  阅读(200)  评论(0编辑  收藏  举报

导航