从命令提示符运行exe


10

如何从命令提示符下运行.exe文件?

例如,如果.exe文件位于C:\file.exe,则提示当前位于另一个位置时,如何运行此文件D:\

Answers:


16

您可以使用显式路径来运行它:

c:\file.exe

或将其位置添加到路径中(我总是有ac:\ bin目录来保存我的小片段-对于多用户Windows来说并不是真正的粗略位置,但我的Windows安装都不是多用户的):

copy c:\file.exe c:\bin  :: put it in a better directory.
path %path%;c:\bin       :: if not already in the path.
file                     :: run it (unless there is another 'file' in path).

请注意,在第二种解决方案中,您应该设置路径,以便每次启动时都可用(如果您确实使用DOS,则在autoexec.bat中;如果您使用Windows,则从Control Panel -> System -> Environment窗口中)。

并且,请注意,如果使用控制面板解决方案,则不会影响当前打开的命令窗口-您需要关闭它们并重新打开以选择新的环境变量。



1

您应该将c:\路径添加到Windows系统的PATH中,这样无论您使用的是什么驱动器,以及在执行file.exe时,Windows都会查看您定义的路径并在其中运行程序。

为此,请转到Windows-我的电脑-在属性上单击鼠标右键-高级按钮-环境变量-在窗口的底部,您将看到PATH-编辑它,添加; c:\并保存这应该可行-我认为它将需要重启


1

要切换驱动器,只需键入C:并按Enter。要更改目录,请键入cd somedirectory

假设我在 D:\Brad,我想跑步C:\Windows\notepad.exe。您可以像其他人建议的那样直接键入它的名称,也可以这样做:

C:
cd \Windows
notepad

0

运行您不知道其全名的EXE文件的最佳方法是:

假设您的文件名是,Installer_4756873653.exe但是您不知道全名,Installer_并且文件的位置是C:\

cd C:\
dir Installer_*.* /b > FileToRun.bat
FileToRun.bat

3
为什么不只键入“安装程序”,然后单击选项卡?
Daniel R Hicks 2012年

在脚本中可能很有用。
vadipp 2014年

0

创建.bat或.cmd文件并将内容写入

cd your_directory_one启动filename.exe

cd your_directory_second开始filename.exe

它对我有用

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.