I am using gnu make 3.8.1 (mingw32) in Windows 7 operating system.
I want to run 'start' command from makefile but it is giving some error. my syntax of command is-
start CMD /K http-server ./www -c-1
This command works when manually typed in cmd. It opens a new command prompt which runs the command 'http-server ./www -c-1', hosts the files present in www folder of current directory on port 8080 and shows the logs in the command prompt window it opened.
but in makefile, it doesn't seems to work. My makefile is-
hostx:
start CMD /K http-server ./www -c-1
There is more to the makefile but we only need to focus on this part.
when i type 'make hostx' in cmd it shows the following output.
I am posting my cmd output as complete image so this is more clear
any ideas how i could get it to work? also i don't know what does this error mean.
Only Windows 95/98/ME have a program called start.exe, in other versions of Windows it is an internal command inside cmd.exe.
To use the start command you need to invoke cmd.exe first:
CMD /C start CMD /K http-server ./www -c-1
If http-server is a console program or batch file then you don't need the CMD /K part because Windows will create a new console automatically. CMD /C start http-server ./www -c-1 should be enough.
Related
There are a number of examples on the web of how to run a file from the Notepad Plus Plus (NPP). But they all fail to account for the fact that the current working directory is the location of the NPP's executable, and not the location of the file.
Usually they go something like this:
cmd /K "$(FULL_CURRENT_PATH)"
Consider the following Python script:
with open('somefile.txt', 'a') as file:
file.write('Hello there.\n')
This file will be created in the NPP folder, which is not at all what most people would expect. Most people would want it in the same location as the Python file.
You could also do something like this, and it works as expected, but this limits you to Python files only:
<Command name="Run This Python File" Ctrl="no" Alt="no" Shift="yes" Key="116">cmd /K python "$(FULL_CURRENT_PATH)"</Command>
I would not want to add extra code to the Python script to change the current working directory, as normally this would not be needed.
I have been trying to solve this and came up with the following. This line goes in "shortcuts.xml" in the NPP folder.
<Command name="Run This File" Ctrl="yes" Alt="no" Shift="no" Key="116">cmd /K "cd "$(CURRENT_DIRECTORY)" && "$(FULL_CURRENT_PATH)""</Command>
So you shut down the NPP, edit the "shortcuts.xml" by adding this line, using another editor, then launch the NPP.
To run the file, use Ctrl+F5 key combination.
This works in Windows 10, but fails in Windows XP.
How can I tweak it to work in Windows XP?
Try this:
cmd /k cd /d $(CURRENT_DIRECTORY) && python $(FULL_CURRENT_PATH)
My guess would be that the problem is the improperly nested quotes in the command; I'm not sure exactly why it would work on later Windows' while failing on XP.
The command
cmd /K "cd "$(CURRENT_DIRECTORY)" && "$(FULL_CURRENT_PATH)""
represents
cmd /K "cd "$(CURRENT_DIRECTORY)" && "$(FULL_CURRENT_PATH)""
Even from the syntax highlighting you can see that the quotes are not quoting what you expect.
To get the desired effect, you can use this command:
cmd /K cd "$(CURRENT_DIRECTORY)" ^&^& "$(FULL_CURRENT_PATH)"
:: XML-ified:
cmd /K cd "$(CURRENT_DIRECTORY)" ^&^& "$(FULL_CURRENT_PATH)"
I run several Windows .bat files from Notepad++. To achieve this one of the entries in the <UserDefinedCommands> section of the file C:\Users\AdrianHHH\AppData\Roaming\Notepad++\shortcuts.xml is:
<Command name="CD and run file" Ctrl="no" Alt="no" Shift="no" Key="0">cmd /C "cd /d $(CURRENT_DIRECTORY) && $(FULL_CURRENT_PATH)"</Command>
With the .bat as the current file I then use menu => Run => CD and run file.
The command line shown in the question appears to have too many " symbols. The current directory includes the drive specifier and so the CD needs the \D option.
The command I use starts cmd \C ... (rather than the \K in the question) so the command window closes automatically. My .bat files normally finish with choice /t 60 /C Y /d Y /n so I can see the command's output.
Notepad++ > F5 (Run) > then type following command
cmd /K cd "$(CURRENT_DIRECTORY)" && python "$(FULL_CURRENT_PATH)"
assuming you have setup the path, or you may use C:\Python27\python.exe or the path of your python binary, and you will run the python at the folder where the python resides in. You can also save this command to shortcut by clicking button Save....
Afterwards, you also can modify the command in toolbar > Run > Modify shortcut/delete command.
I am trying to run the .exe of a programm I donwloaded. But to see why it isn`t working I want to keep the cmd open to see the output it generates. Is that somehow possible?
Use the /K switch: cmd /K "my.exe".
Is there a way to run any command (eg: cd D:\test) on Command Prompt start and to have this instance of Command Prompt as a different shortcut/instance.
You can create a shortcut that has a target of e.g.:
%comspec% /k ""C:\Full_Path_to\VsDevCmd.bat""
Where the .bat file is the command(s) that you want to run on startup. This will then leave you with an open command prompt after those commands have executed.
(In case it's not obvious, this is just shamelessly ripped from one of the Developer Command Prompt shortcuts that Visual Studio installs in the Start Menu)
%comspec% is a nice way of getting cmd to execute.
Cmd:
/k : Carries out the command specified by string and continues.
I've seen it in linux. There's a console you can open that is just a shell. I want the same thing in windows only with either cmd, or with git bash. (MINGW32). I tried googling it but just got flooded with articles about egit and normal git bash.
If you have msysgit, you can use it from a regular cmd session:
Launch c:\windows\system32\cmd.exe /k <path\to\your\msysgit>\git-cmd.bat, and you can type in that cmd windows regular git commands.
For a bash session: c:\windows\system32\cmd.exe /k <path\to\your\msysgit>\git-bash.bat.
Note that you need to modify those bat:
git-cmd.bat: add a rem before the setlocal command, and before the start at the end.
git-bash.bat: add a rem before the setlocal command.
So you can add to your Eclipse an external tool which will open a cmd in your console:
Except, instead of calling C:\windows\system32\cmd.exe (in the "Location" field from the picture above), you could call directly: C:\windows\system32\cmd.exe /k <path\to\your\msysgit>\git-bash.bat.
By 'msysgit', I refer to whatever name you gave to the uncompresdsed portable version of "Git For Windows": download it there.
And then you could type git command within the Eclipse console (including a bash session)!
After testing, the color codes get in the way, even if git works:
git-cmd.bat:
git-bash.bat:
This must be a real dumb question. And I cant figure out how.
What I want to do is launch a new command line with some arguments and excute some commands there.
Here is what I have in my .cmd
CMD /k %EnvInstallPath% %wo% %var%
cd /d %wo%\src
When I execute test.cmd, I see that the directory changes to %wo%, but the further cd src is not executed. I need to cd to a directory and execute few other commands.
When you run cmd with /k the console runs the command and then resumes with the prompt. I'm guessing that what you want is to run the command and resume with the next one, so you need to run cmd with /c instead.
put the other commands in a different bat file and
start AFewOtherCommands.bat