PC Review


Reply
Thread Tools Rate Thread

compile and run

 
 
George Hester
Guest
Posts: n/a
 
      17th Mar 2005
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.

--
George Hester
_________________________________

 
Reply With Quote
 
 
 
 
David Candy
Guest
Posts: n/a
 
      17th Mar 2005
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).
--
----------------------------------------------------------

"George Hester" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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.

--
George Hester
_________________________________

 
Reply With Quote
 
George Hester
Guest
Posts: n/a
 
      19th Mar 2005
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 news:(E-Mail Removed)...
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).
--
----------------------------------------------------------

"George Hester" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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.

--
George Hester
_________________________________


 
Reply With Quote
 
Stefan Kanthak
Guest
Posts: n/a
 
      19th Mar 2005
"George Hester" <(E-Mail Removed)> wrote:

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

 
Reply With Quote
 
George Hester
Guest
Posts: n/a
 
      20th Mar 2005
"Stefan Kanthak" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> "George Hester" <(E-Mail Removed)> wrote:
>
> 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.

--
George Hester
_________________________________

 
Reply With Quote
 
George Hester
Guest
Posts: n/a
 
      20th Mar 2005
"Stefan Kanthak" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> "George Hester" <(E-Mail Removed)> wrote:

<snip>
> 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.

--
George Hester
_________________________________

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile versus not compile (VS 2005)?? stupid48@gmail.com Microsoft ASP .NET 1 11th Apr 2008 09:24 PM
Why did this compile? John A. Bailo Microsoft Dot NET 5 15th Apr 2006 08:21 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Microsoft Excel Programming 1 13th Dec 2005 07:17 PM
can i fine tune VS.Net compile/ use parallel process when compile? norton Microsoft Dot NET 0 1st May 2004 07:09 PM
Using vbc to compile =?Utf-8?B?RmF0Ym95Q2FudGVlbg==?= Microsoft Dot NET Framework Forms 1 13th Feb 2004 12:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:08 PM.