set dd=cd
doskey cd=cd $* ^&call title %^%dd^%%
Indeed it does! Kudos to you for figuring that out.
set dd=cd&doskey cd=cd $* ^&call title %^%dd^%%
crossposted to crossposted to microsoft.public.windowsxp.general
Kenny,
For some "odd reason" I had the same question but posted it into the microsoft.public.windowsxp.general. Herbert Kleebauer alerted me to this thread.
set dd=cd
doskey cd=cd $* ^&call title %^%dd^%%
Indeed it does! Kudos to you for figuring that out.
Herbert also posted your final(?) solution :
set dd=cd&doskey cd=cd $* ^&call title %^%dd^%%
I think that you have found out by now that that doesn't quite work. For multiple reasons :
Take a look at what "doskey /macros" shows you. You might notice that the stored command replacement is this : "cd=cd $* &call title dd%". Which ofcourse means that the title of your command window will always be "dd%"
set dd=cd&doskey cd=cd $* ^&call title %^%dd^%%cd=cd $* &call title %%dd%%
doskey /macros
Easy to fix, either use "^%%dd^%%" - or just "%%dd%%". ("^%dd^%" doesn't work)
The biggest problem however is that the "set dd=cd&" part of your command isn't stored in the doskey command replacement. Which ofcourse means that
the current directory is ony *once* stored into the "dd" variable, and than used for all the window captions. And I don't think that is what you want(ed). :-)
Also, IFAIKS that "call" in there is not needed.
With the help of JJ I found a solution which seems to work nicely :
doskey cd=cd /d $* ^& for %%A in (.) do @title %%~nxA
(caveat: I did my work under XPsp3)
I think that you have found out by now that that doesn't quite work. For
multiple reasons :
Did you try it? Here it works.
Easy to fix, either use "^%%dd^%%" - or just "%%dd%%". ("^%dd^%" doesn't
work)
The fix is the bug!
The biggest problem however is that the "set dd=cd&" part of your command
isn't stored in the doskey command replacement. Which ofcourse means
that
It don't have to be stored in the doskey macro. It is just a one line replacement for:
Not the current directory is stored in the variable "dd" but the string
"cd"
Also, IFAIKS that "call" in there is not needed.
Without the call it wouldn't work.
As a check I put the above in a batchfile,
You shouldn't have done that. Just enter it at the command prompt.
As a check I put the above in a batchfile,
You shouldn't have done that. Just enter it at the command prompt.
Ackkk.... thats quite a bit of a difference. I've just tried it that way and it works. And now I also understand why you need that "call" in
there.
Not usefull to me though, as I have zero wish to type it in every time I
open a command window. :-(
And I would still suggest to put that "set dd=cd" part *inside* the doskey macro - other batchfiles could overwrite the "dd" environment variable and leave you with unexpected results.
crossposted to crossposted to microsoft.public.windowsxp.general
Kenny,
For some "odd reason" I had the same question but posted it into the >microsoft.public.windowsxp.general. Herbert Kleebauer alerted me to this >thread.
It does work on the command line but not in a batch file. If you want
to use it in a batch file, you have to add a few %:
set dd=cd
doskey cd=cd $* ^&call title %%%%dd%%%%
You can use any name which is not used by other batch code instead of
"dd".
And as is appears now I was just too focussed on keeping those "^" in
there. You /said/ they where part of the solution. :-)
Keep in mind that most of what you attribute to me (as in, "Your (Kenny's) code, blah, blah, blah") is not mine at all. Most of it was dreamed up, composed, and posted by Herbert. So, credit where credit is due.
I got a brainfart and thought of something else to try :
Kenny,
Keep in mind that most of what you attribute to me (as in, "Your (Kenny's) >> code, blah, blah, blah") is not mine at all. Most of it was dreamed up,
composed, and posted by Herbert. So, credit where credit is due.
My apologies to both of you. I thought it was you who put it together with >Herbert commenting upon it.
Herbert,
I wrote :
I got a brainfart and thought of something else to try :
Got another one : no intermediate environment variable and, IMHO, even
easier to work with :
set doskey cd=cd $* ^&call title %%c^^d%%
(from within a batchfile)
... I must have /way/ to much time on my hands.
Got another one : no intermediate environment variable and, IMHO, even
easier to work with :
set doskey cd=cd $* ^&call title %%c^^d%%
(from within a batchfile)
That is a good one. For me batch programming is "trial and error" and I
would have never found this solution.
set doskey cd=cd $* ^&call title %%c^^d%%
(from the within a batchfile)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 339 |
Nodes: | 16 (2 / 14) |
Uptime: | 01:00:07 |
Calls: | 7,467 |
Calls today: | 3 |
Files: | 12,691 |
Messages: | 5,627,865 |