How to run a simple Windows command?
This command:
exec.Command("del", "c:\aaa.txt")
.. outputs this message:
del: executable file not found in %path%
What am I doing wrong?
How to run a simple Windows command?
This command:
exec.Command("del", "c:\aaa.txt")
.. outputs this message:
del: executable file not found in %path%
What am I doing wrong?
C:> assoc .py=Python
C:> ftype Python="C:python27python.exe %1 %*"
Or whatever the relevant path is - you can also set command line args using ftype.
In order to make a command recognized without having to give the suffix (.py
), similar to how it works for .exe
files, add .py
to the semi-colon separated list of the (global) PATHEXT
variable.
ETA 2017-07-27
Seems like this is still getting eyeballs, wanted to elevate a useful comment for Win10 users (from @shadowrunner):
For me to get it work under Win10 the actual command was (note the placement of the quotes):
C:> ftype Python="c:Anaconda2python.exe" "%1" %*
ETA 2019-02-01
Talk about evergreen!
First of all, if you're newly installing Python, I highly recommend reviewing the answer by @NunoAndré .
Secondly, to clarify something from a recent comment, please note: you must do both parts (assoc
and ftype
), or use a pre-existing association label in the ftype
command.
By default, at least for Python 3.7 under Windows 8.1, the association for .py
is Python.File
, so performing the ftype
command I wrote above will not work correctly unless the association is first changed. Or you can just use ftype
and give the default association instead. Up to you.
The "cd" command changes the directory, but not what drive you are working with. So when you go "cd d:temp", you are changing the D drive's directory to temp, but staying in the C drive.
Execute these two commands:
D:
cd temp
That will get you the results you want.
Yes, you have to install a compiler, Eclipse is only an IDE. You can get MinGW here.
App Paths
registry settings - used by Windows Explorer, to locate programs when you type program name in "Run..." box, and so on. These settings are not affecting cmd.exe
behavior.
The only way to set up cmd.exe
paths for searching applications is changing PATH
environment variable. You can start cmd.exe
from your own .bat
/.cmd
where you set up all required variables for current session, without changing it globally.
I got the same error as you. But dystroy is correct: You can't run
del
or any other command built intocmd
because there is nodel.exe
file (or any other del-executable for that matter).I got it to work with: