如何在Windows 7系统中使用bat文件更改为子目录并运行exe? [英] How to change to a subdirectory and run an exe using a bat file in a Windows 7 system?

查看:149
本文介绍了如何在Windows 7系统中使用bat文件更改为子目录并运行exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用bat文件,我想转到bat文件所在的文件夹的子目录,然后在该目录中运行my_application.exe

Using a bat file, I want to change to a sub directory of folder which bat file is in, and run my_application.exe in that directory,

我尝试:

cd /d %cd%\my subdirectory
START %~dp0my_application.exe

但是它不起作用,它说找不到my_application.exe

But it doesn't work, it says it can't find my_application.exe

推荐答案

只需向start命令指示要启动的程序,以及该程序的起始文件夹.

Just indicate to start command what program to start and what should be the starting folder for it.

没有cd命令,它可以写为

start "" /d "%~dp0my_subdirectory" "my_application.exe"

如果my_application.exe位于子目录中,则为

if the my_application.exe is located in the subdirectory, or

start "" /d "%~dp0my_subdirectory" "%~dp0my_application.exe"

如果应用程序与批处理文件位于同一文件夹中.

if the application is located in the same folder as the batch file.

start命令采用第一个带引号的参数作为新进程的标题.为避免出现问题,命令中包含一个空字符串("")作为标题.

start command take the first quoted parameter as the title for the new process. To avoid problems, a empty string ("") is included in command as the title.

这篇关于如何在Windows 7系统中使用bat文件更改为子目录并运行exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆