running an exe from NppExec - cmd

I'm making a script to compile and run an entire project on Notepad++ using NppExec.
I keep each project on a folder and each folder has a makefile to compile the entire project, the compiler will produce a single .exe file so in each folder there is just one executable that has the same name of the folder (with the .exe extension).
I made the first part of the script (compiling with the makefile) but I don't know how to make the second part (running the executable). I know how to run an executable in NppExec but I'm trying to do something different: I want to compile the exe without specifying its name in the commands so that I can use the script to compile and run every project organized as I explained above (each folder with only one .exe that has the same name of the folder).
How can I do it?
If you don't know how to do that in NppExec, how can I do the same thing in cmd? (I can then write that in NppExec by adding cmd \c at the and of the command)

There are some special targets make knows about:
all: to compile everything
run: to run the program, if this depends on all, then the program is recompiled if necessary
clean: for necessary clean ups
So what you need are two npp_exec scripts which you can bind to different keyboard shortcuts (save the scripts under some names, in the menu use Plugins, Nppexec, Advanced options: add the scripts to the menu using the controls on the left; give the menu items different menu_names; restart notepad++; goto Settings, Shortcut mapper, Plugins commands: you will find the menu_names somewhere in this list, you can assign keyboard shortcuts to them).
The second ingredient are the targets in the makefile:
all: depends on your binary
run: depends on all, the command would normally be something like
./$(ProgName)
but in your case (windows with mingw32-make, as explained in the comments, and you need a command window) your run target would look like
run: all
cmd /C $(ESEGUIBILE)
This way you have one setup in Notepad++ that works for all your folders, the interface is
make all
make run
The makefiles in each folder know the name of the folder specific binary, you only need to add the run section to each makefile.

Related

Makefile.mak giving error [duplicate]

I have Windows 7 and tried to use the 'make' command but 'make' is not recognized as an internal or external command.
I did Start -> cmd -> run -> make, which outputs:
'make' is not recognized as an internal or external command,operable program or batch file.
Then I typed 'mingw32-make' instead of 'make' (Start -> cmd -> run -> mingw32-make) and I get the same output:
'mingw32-make' is not recognized as an internal or external command,operable program or batch file.
What shall I do next in order to fix this problem?
In Windows10, I solved this issue by adding C:\MinGW\bin to Path and then called it using MinGW32-make not make.
Your problem is most likely that the shell does not know where to find your make program. If you want to use it from "anywhere", then you must do this, or else you will need to add the full path each time you want to call it, which is quite cumbersome. For instance:
"c:\program files\gnuwin32\bin\make.exe" option1=thisvalue option2=thatvalue
This is to be taken as an example, it used to look like something like this on XP, I can't say on W7. But gnuwin32 used to provide useful "linux-world" packages for Windows. Check details on your provider for make.
So to avoid entering the path, you can add the path to your PATH environment variable. You will find this easily.
To make sure it is registered by the OS, open a console (run cmd.exe) and entering $PATH should give you a list of default pathes. Check that the location of your make program is there.
This is an old question, but none of the answers here provide enough context for a beginner to choose which one to pick.
What is make?
make is a traditional Unix utility which reads a Makefile to decide what programs to run to reach a particular goal. Typically, that goal is to build a piece of software from a set of source files and libraries; but make is general enough to be used for various other tasks, too, like assembling a PDF from a collection of TeX source files, or retrieving the newest versions of each of a list of web pages.
Besides encapsulating the steps to reach an individual target, make reduces processing time by avoiding to re-execute steps which are already complete. It does this by comparing time stamps between dependencies; if A depends on B but A already exists and is newer than B, there is no need to make A. Of course, in order for this to work properly, the Makefile needs to document all such dependencies.
A: B
commands to produce A from B
Notice that the indentation needs to consist of a literal tab character. This is a common beginner mistake.
Common Versions of make
The original make was rather pedestrian. Its lineage continues to this day into BSD make, from which nmake is derived. Roughly speaking, this version provides the make functionality defined by POSIX, with a few minor enhancements and variations.
GNU make, by contrast, significantly extends the formalism, to the point where a GNU Makefile is unlikely to work with other versions (or occasionally even older versions of GNU make). There is a convention to call such files GNUmakefile instead of Makefile, but this convention is widely ignored, especially on platforms like Linux where GNU make is the de facto standard make.
Telltale signs that a Makefile uses GNU make conventions are the use of := instead of = for variable assignments (though this is not exclusively a GNU feature) and a plethora of functions like $(shell ...), $(foreach ...), $(patsubst ...) etc.
So Which Do I Need?
Well, it really depends on what you are hoping to accomplish.
If the software you are hoping to build has a vcproj file or similar, you probably want to use that instead, and not try to use make at all.
In the general case, MinGW make is a Windows port of GNU make for Windows, It should generally cope with any Makefile you throw at it.
If you know the software was written to use nmake and you already have it installed, or it is easy for you to obtain, maybe go with that.
You should understand that if the software was not written for, or explicitly ported to, Windows, it is unlikely to compile without significant modifications. In this scenario, getting make to run is the least of your problems, and you will need a good understanding of the differences between the original platform and Windows to have a chance of pulling it off yourself.
In some more detail, if the Makefile contains Unix commands like grep or curl or yacc then your system needs to have those commands installed, too. But quite apart from that, C or C++ (or more generally, source code in any language) which was written for a different platform might simply not work - at all, or as expected (which is often worse) - on Windows.
First make sure you have MinGW installed.
From MinGW installation manager check if you have the mingw32-make package installed.
Check if you have added the MinGW bin folder to your PATH. type PATH in your command line and look for the folder. Or on windows 10 go to Control Panel\System and Security\System --> Advanced system settings --> Environment Variables --> System Variables find Path variable, select, Edit and check if it is there. If not just add it!
As explained here, create a new file in any of your PATH folders. For example create mingwstartup.bat in the MinGW bin folder. write the line doskey make=mingw32-make.exe inside, save and close it.
open Registry Editor by running regedit. As explained here in HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER go to \Software\Microsoft\Command Processor right click on the right panel New --> Expandable String Value and name it AutoRun. double click and enter the path to your .bat file as the Value data (e.g. "C:\MinGW\bin\mingwstartup.bat") the result should look like this:
now every time you open a new terminal make command will run the mingw32-make.exe. I hope it helps.
P.S. If you don't want to see the commands of the .bat file to be printed out to the terminal put #echo off at the top of the batch file.
If you already have MinGW installed in Windows 7, just simply do the following:
Make another copy of C:\MinGW\bin\mingw32-make.exe file in the same folder.
Rename the file name from mingw32-make.exe to make.exe.
Run make command again.
Tested working in my laptop for above steps.
For window-10 resolved error- make' is not recognized as an internal or external command.
Download MinGW - Minimalist GNU for Windows from here https://sourceforge.net/projects/mingw/
install it
While installation mark all basic setup packages like shown in image
Apply changes
After completion of installation
copy C:\MinGW\bin
paste in system variable
Open MyComputer properties and follow as shown in image
You may also need to install this
https://sourceforge.net/projects/gnuwin32/
As other answers already suggested, you must have MinGW installed. The additional part is to add the following two folders to the PATH environment variable.
C:\MinGW\bin
C:\MinGW\msys\1.0\bin
Obviously, adjust the path based on where you installed MinGW. Also, dont forget to open a new command line terminal.
'make' is a command for UNIX/Linux. Instead of it, use 'nmake' command in MS Windows. Or you'd better use an emulator like CYGWIN.
Search for make.exe using the search feature, when found, note down the absolute path to the file. You can do that by right-clicking on the filename in the search result and then properties, or open location folder (not sure of the exact wording, I'm not using an English locale).
When you open the command line console (cmd) instead of typing make, type the whole path and name, e.g. C:\Windows\System32\java (this is for java...).
Alternatively, if you don't want to provide the full path each time, then you have to possibilities:
make C:\Windows\System32\ the current working directory, using cd at cmd level.
add C:\Windows\System32\ to you PATH environment variable.
Refs:
use full path: http://technet.microsoft.com/en-us/magazine/ff678296.aspx
cd: http://technet.microsoft.com/en-us/library/cc731237.aspx
PATH: http://technet.microsoft.com/en-us/library/bb490963.aspx
I am using windows 8. I had the same problem. I added the path "C:\MinGW\bin" to system environment variable named 'path' then it worked. May be, you can try the same. Hope it'll help!
try download & run my bat code
======run 'cmd' as admin 2 use 'setx'=====
setx scoop "C:\Users%username%\scoop" /M
echo %scoop%
setx scoopApps "%scoop%\apps" /M
echo %scoopApps%
scoop install make
=======Phase 3: Create the makePath environment variable===
setx makePath "%scoopApps%/make" /M
echo %makePath%
setx makeBin "%makePath%/Bin" /M
echo %makeBin%
setx Path "%Path%;%makeBin%" /M
echo %Path%
use mingw32-make instead of cmake in windows

Any way to automate a folder delete before building?

Basically, I want to delete the folder named:
build-[Project Name]-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug
before compiling.
Go to project settings (Ctrl+5, a.k.a. 5th mode), and add new build step with custom command 'rmdir', and arguments '/s /q path-to-target-directory'.
Don't forget that custom build step should be on top of list, before 'qmake' step.
Take a look at system command for qmake, which allows executing any shell command of the operating system:
http://harmattan-dev.nokia.com/docs/library/html/qt4/qmake-function-reference.html#system-command
In windows you can put
system(rmdir /Q /S "build-[Project Name]-Desktop_Qt_5_0_2_MSVC2010_32bit-Debug")
in your .pro file. If you need other platforms, you can check which platform it is and call appropriate shell command for that platform using same syntax.

What is the simplest program I can write to invoke a batch script?

It is very stupid that windows will not let you add batch files to your quick launch or whatever they call in in windows 7. That bar across the bar, i can attach firefox there, command prompt, even paint (my favorite), but not a batch file. I can "pin" it to another program, which is just weird. I want it to standalone, the batch file does enough work by itself.
So lets say i have batch file. What is the simplest executable program I can write to invoke said script. Then I can finally pin all my useful batch files on that quick-jump-pin-bar.
If I remember right, you can do this by first pinning a shortcut to CMD.exe to the taskbar. Then edit the command, and change CMD.exe to CMD.exe /c MyBatchFile.bat. I believe this will execute the batch file.
Since you can only pin one cmd, here's an alternative, assuming you have the .NET framework installed - a very simple C# application:
Populate a textfile with the following contents:
class Program {
static void Main() {
System.Diagnostics.Process.Start(#"c:\test.bat");
}
}
where Program is the name of the executable you want to create, and c:\test.bat is the full path to the batch file. Save the file as Program.cs. Execute the following from the command line:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe Program.cs
You can replace 2.0.50727 with whatever directory exists on your machine - might be 1.1.something or 3.5 or 4.0.something - it's all the same for this scenario.
This will generate Program.exe. You can put that exe file wherever you want, and pin that executable to the taskbar. You can discard the .cs file once you're done making your executables.
Kind of a crappy solution, but it should work, assuming you don't find anything better. And if you don't have the .NET framework (which I'm not sure is even possible in Windows 7), you can install it pretty easily.
The easiest way is to create a folder, put your batch files in it, and pin the folder to the menu bar :D
You can also write a startup script, so the batch file will be executed on startup, but I don't know if you want to run those scripts on every bootup... You can also add the command prompt to the bar, and edit the startup path..
Use command switches on CMD.exe.
cmd.exe /c "myscript.bat"
As a sort of workaround you could use the following trick. Pin an arbitrary application to the task bar, Shift+right click on the pinned icon, select Properties, change 'Target' and 'Start in' accordingly. Rename it too if you like.
You can pin more than one .bat file using this technique.

How can I rename a VB6 executable?

I'm trying to automate a VB6 build where different apps are built from the same source by:
Changing "Conditional Compilation Arguments".
"Make Project" to a different executable name.
I can do part of this on the command line:
VB6.EXE /m Project.VBP /d BUILD_OTHER_APP=1
but the executable still has the name "Project.exe". If I rename the .EXE it stops working (doesn't seem to run). VB6 doesn't seem to have a command line option to set the executable name and I can't get round this problem with renaming.
I'm using VB6 on Win7 32-bit.
If you run VB6 /? from the command line a dialog box pops up to tell you all the options, and no, it seems that there isn't an option to specify the output filename.
I can't as yet see any reason for a rename to stop an executable working, but I'll try this later on today on Win XP.
The other workaround to renaming is to move the executables into folders of different names and create shortcuts or batch files of different names to call the correct executable.
edit: I'm working on Win XP and these two solutions are available to me:
Rename the executable - You might be able to develop on XP and run on Win7?
Add the .exe name to the build command line. This does override the .vbp:
VB6 /m Project1 /d conHello=-1 Hello.exe
VB6 /m Project1 /d conHello=0 World.exe
The hack that we are forced to do to create a different named output (and to change other aspects of the project) is to create a copy of the VBP (Project_tmp.vbp), and then change the name in the copy and build from that copy.

Helping my users find the installer on the CD

I need suggestions about a setup CD layout for non technical users.
My software is deployed on a CD with a setup.exe bootstrapper and a MSI file. There are also several dependency files used by the installer. The CD root looks something like this:
myapp.msi
setup.exe
sqlexpr32.exe
dotnetfx.exe
myapp.ico
...
It is not rocket science for a developer guessing that the file you need to run in order to begin the installation is setup.exe.
But my users are definitely not as tech-savvy.
I have included an autorun.inf file, but I have found after testing in several machines that most of them do not automatically launch the setup. For whatever reason. In some machines somebody has disabled autorun, or some antivirus software, or whatever. The thing is that I cannot rely on autorun being available at all times.
So I'm thinking making changes to the CD layout in order to make more obvious which file has to be run.
One option is to make a new Install.exe program that just launches the original bootstrapper, and moving everything to a folder in the root of the CD:
autorun.inf <-- launches Install.exe, if autorun is enabled for the drive.
Install.exe <-- launches contents/setup.exe
contents/myapp.msi
contents/setup.exe
contents/sqlexpr32.exe
contents/dotnetfx.exe
contents/myapp.ico
contents/...
As I cannot yet rely on the .net framework being present, I cannot use .net to make my Install.exe and that is kind of annoying.
Other option is making a Install.bat but most users are not familiar with the .bat extension and might not think about double-clicking it. And the user would see a command prompt window.
Other option is making a self-extracting exe and compressing everything inside, so the only files in the CD would be the autorun.inf and the self-extracting file.
What would you do?
Other option is making a Install.bat but most users are not familiar with the .bat extension and might not think about double-clicking it. And the user would see a command prompt window.
You could create a shortcut to the Install.bat and give it a pretty icon and a nicer name. You can also make it start minimised, so they probably wouldn't notice the command prompt appearing briefly.
EDIT: (By Sergio Acosta)
I found out how to solve the relative path issue:
This is how the shortcut should be configured:
Target: %windir%\system32\cmd.exe "/C start contents\setup.exe"
Start in: %cd%
Run: Minimized
Icon: %SystemRoot%\system32\SHELL32.dll (and manually select the one that looks like a setup package.
I have tested it and it works.
Keep it simple, instead of thinking to much of the layout, go by conventions and leave the setup.exe or install.exe and provide a README.txt file where they can find installation instructions. Most users will choose install.exe or setup.exe and other will probably read the txt.
Put a big sticker on the CD that reads "Run Setup.exe".
I think that the simplest option you have mentioned, to make a new Install.exe program that just launches the original bootstrapper, and having nothing else except the Autorun at the root of the CD, is the best choice.
One icon = no options. Can't really do better than this.
Though I like the solution with the shortcuts, it may be an alternative also to use the free "Bat To Exe Converter".
This way your users will see a standard-looking EXE with any custom icon you want. Plus you can configure it to be run invisible so there won't even be a minimized CMD box.

Resources