compile and run

G

George Hester

I made a entry in the Windows 2000 registry to compile and build a C program from a make file. Like this:

HKCR\.mak
default: makfile

HKCR\makfile
HKCR\makfile\shell
HKCR\makfile\shell\Open2
default: Open &with command prompt

HKCR\makfile\shell\Open2\command
default: cmd /k nmake "%1" %*

What I would like to do is run the exectable that results. I assume I would need to pipe into that (success) exectable which is the same name as the mak file less the extension with exe of course. Is it possible to do this as I have set it up or maybe I should set this tpo use a bat file and in that run nmake and then the file itself? Either way how can I do this? Of course if the build fails I would like to exit nicely. Thanks.
 
D

David Candy

As you are using cmd you can do anything

There is no need for %*, you can ONLY pass a filename so only need %1.

In cmd %1 can be modified.%~n1 is the file name (~ to show we are pulling out parts of the full name, n for name, d for drive, n for name, x for extension. && seperates commands on a line and depends on sucess to execute.

"c:\windows\system32\cmd" /k nmake "%1" && "%~dpn1"

You also haven't given a path to cmd so explorer won't find it (it wants to look to see if it's a win32 aware program so it can decide to pass long/short names) and will pass short names to CreateProcess (which will find Cmd so it will work but with short names as parameters). You really should quote the full path to cmd (although cmd is usually is a folder without spaces - so quotes are optional usually)

Type cmd in help and read the quoting rules. I've found that spaces as delimiters work (normally / & etc are also considered delimeters).
--
----------------------------------------------------------

I made a entry in the Windows 2000 registry to compile and build a C program from a make file. Like this:

HKCR\.mak
default: makfile

HKCR\makfile
HKCR\makfile\shell
HKCR\makfile\shell\Open2
default: Open &with command prompt

HKCR\makfile\shell\Open2\command
default: cmd /k nmake "%1" %*

What I would like to do is run the exectable that results. I assume I would need to pipe into that (success) exectable which is the same name as the mak file less the extension with exe of course. Is it possible to do this as I have set it up or maybe I should set this tpo use a bat file and in that run nmake and then the file itself? Either way how can I do this? Of course if the build fails I would like to exit nicely. Thanks.
 
G

George Hester

I must not have done this right. I now have this in the command key:

cmd /k nmake "%1" && "%~dpn1"

The result was:

'"%~dpn1"' is not recognized as an internal or external command, operable program or batch file

The way this works (1/2 of it anyway) is right-click the mak file and choose Open with command prompt. It compiles and builds just fine. But getting the result (the executable which is the same name as the mak file less the .mak extension replaced with .exe extension) to fire is what I was hoping was going to happen. It compiled and built fine but didn't fire instead the error message above was what resulted.

--
George Hester
_________________________________
"David Candy" <.> wrote in message As you are using cmd you can do anything

There is no need for %*, you can ONLY pass a filename so only need %1.

In cmd %1 can be modified.%~n1 is the file name (~ to show we are pulling out parts of the full name, n for name, d for drive, n for name, x for extension. && seperates commands on a line and depends on sucess to execute.

"c:\windows\system32\cmd" /k nmake "%1" && "%~dpn1"

You also haven't given a path to cmd so explorer won't find it (it wants to look to see if it's a win32 aware program so it can decide to pass long/short names) and will pass short names to CreateProcess (which will find Cmd so it will work but with short names as parameters). You really should quote the full path to cmd (although cmd is usually is a folder without spaces - so quotes are optional usually)

Type cmd in help and read the quoting rules. I've found that spaces as delimiters work (normally / & etc are also considered delimeters).
--
----------------------------------------------------------

I made a entry in the Windows 2000 registry to compile and build a C program from a make file. Like this:

HKCR\.mak
default: makfile

HKCR\makfile
HKCR\makfile\shell
HKCR\makfile\shell\Open2
default: Open &with command prompt

HKCR\makfile\shell\Open2\command
default: cmd /k nmake "%1" %*

What I would like to do is run the exectable that results. I assume I would need to pipe into that (success) exectable which is the same name as the mak file less the extension with exe of course. Is it possible to do this as I have set it up or maybe I should set this tpo use a bat file and in that run nmake and then the file itself? Either way how can I do this? Of course if the build fails I would like to exit nicely. Thanks.
 
S

Stefan Kanthak

Top-posting is nasty!
And your line length sucks. Please break them at 70 chars.
I must not have done this right. I now have this in the command key:

cmd /k nmake "%1" && "%~dpn1"

The result was:

'"%~dpn1"' is not recognized as an internal or external command,
operable program or batch file

Open a command prompt and enter

call /?
%comspec% /? (or cmd.exe /?)
set /?
for /?

%~...<n> can be used with positional operands of and IN batch files and
with for variables only.
The "shell" only knows %0 to %9, %*, %L and %I.
You'll have to use REG_EXPAND_SZ:%ComSpec% /K <full path to your *.cmd>
and write nmake "%1" && "%~dpn1" to this *.cmd.

[...cut...]

Stefan
 
G

George Hester

Stefan Kanthak said:
Top-posting is nasty!
And your line length sucks. Please break them at 70 chars.
I must not have done this right. I now have this in the command key:

cmd /k nmake "%1" && "%~dpn1"

The result was:

'"%~dpn1"' is not recognized as an internal or external command,
operable program or batch file

Open a command prompt and enter

call /?
%comspec% /? (or cmd.exe /?)
set /?
for /?

%~...<n> can be used with positional operands of and IN batch files and
with for variables only.
The "shell" only knows %0 to %9, %*, %L and %I.
You'll have to use REG_EXPAND_SZ:%ComSpec% /K <full path to your *.cmd>
and write nmake "%1" && "%~dpn1" to this *.cmd.

[...cut...]

Stefan

Alright I don't think that is going to work either although I am giving it a shot. In the registry the command key must
have (default) %COMSPEC% /K <full path to *.cmd>. But (default) is of type REG_SZ not REG_EXPAND_SZ.
So there's the rub.
 
G

George Hester

Stefan Kanthak said:
"George Hester" <[email protected]> wrote:
The "shell" only knows %0 to %9, %*, %L and %I.
You'll have to use REG_EXPAND_SZ:%ComSpec% /K <full path to your *.cmd>
and write nmake "%1" && "%~dpn1" to this *.cmd.

[...cut...]

Stefan

Well here is how I did it. I assume it could be done better without the make.cmd file but this works:

HKCR\.mak
(default) REG_SZ makfile

HKCR\makfile
HKCR\makfile\shell
HKCR\makfile\shell\Open2
HKCR\makfile\shell\Open2\command
(default) REG_SZ cmd /k nmake "%1" && "make" "%1"

That is the registry settings. There will need to be a make file and this file make.cmd in the folder containing the project and in the make.cmd we have this "%~dpn1"

That does it. Not pretty but works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top