Need drive letter control sequence

I updated my OS to windows 7 64 bit which means some of the programs I used to run using the DOpus DOS icon will no longer run. I decided to solve this problem by adding a new DosBox icon.

I happened to install DOSBOX in a folder called D:\WinU\DOSBox, so I built this user command using the MS-DOS BATCH function:

D:\WinU\DOSBox\DOSBox.exe -conf D:\WinU\DOSBox\config.txt -noconsole -c "CD {sourcepath}

I assigned this to a button on my toolbar.
It works, but there are two problems.
Notice that I don't have a closing quote for the CD command.
The reason I don't have that is because when I put it in, DOSbox gives me an error (for example) that it can't change to directory D:\new"

i.e. it's trying to change to a directory name with a quote on the end.
Somehow DOpus is adding an extra quote!
I know DOSbox can handle something like -c "CD D:\new" on it's command line since I tried that in a shortcut.
I think the reason it works without the final quote is that DOSBox will insert it automatically when the line ends with an unterminated quote.

I even tried adding the line "@nofilenamequoting" before the DOSBox command, but that didn't help.

Despite that problem, with my work around (deleting the trailing quote) it pretty much does the job for me.
However besides CDing to the current directory it would also be nice if it actually changed to the drive in that CD command. The prompt won't actually change to show the "here" directory until this is done.

If there were a {sourceDrive} control sequence or something like that, then I could add a second -c command to the DOSBox string and then it would behave just like the built in DOPus DOS(=here) function. This would also require fixing the extra quote problem so that I could put two commands on the command line.

Thanks in advance for any ideas you may offer.
~Paul

The quote thing is due to an unfortunate "feature" of the way most DOS programs parse command-lines.

Change the command to this and it should work:

D:\WinU\DOSBox\DOSBox.exe -conf D:\WinU\DOSBox\config.txt -noconsole -c "CD {sourcepath|noterm}"

(It probably still won't work in the root of a drive.)

The issue is that {sourcepath} puts a \ on the end of the path (unless you add |noterm) and " at the end of a word on a command-line is (by most programs) parsed as a literal " being part of the argument (rather than a " containing the argument).

I'm not sure but you may also be able to get it to work like this, which if it works at all should also fix the root-path issue:

D:\WinU\DOSBox\DOSBox.exe -conf D:\WinU\DOSBox\config.txt -noconsole -c "CD {sourcepath}\"

That would put a \ at the end which might be parsed as a , followed by a normal ".

BTW, I expect none of these will work if the path contains spaces and needs to be quoted, since then you'll have a quoted path inside the quoted "CD path" at the end. Telling Opus to use the short 8.3 version of the path might be a workaround for that.

Thanks Leo for explaining how to get around the quote problem (noterm). I don't
exactly understand it, but then again I don't really need to since the noterm
solution works great. The alternative backslash method you suggested didn't seem to work.
I used the short path form so paths with spaces in them will still work.
I got around the changing to the drive letter problem by using the command "CWD.COM" an old dos utility I found somewhere which does the same thing as CD with the /D option (since DosBox doesn't support the /D).
So now my final command is:

D:\WinU\DOSBox\DOSBox.exe -conf D:\WinU\DOSBox\config.txt -noconsole -c "CWD {sourcepathshort|noterm}"

This works great, although this opens two windows. A regular dos command window, and then the DosBox command window. If there is a way to suppress the regular dos window, then I will have achieved perfection :slight_smile:

Does anybody know how to suppress or hide that window?

Thanks

Perhaps adding

@Runmode=hide

will supress the window (i didnĀ“t test it, but the manual suggests this command).

Perhaps adding
@Runmode=hide
will supress the window

Good suggestion. Actually I had looked at "runmode" already but the description was not very clear at all. (The "Run" state of the program ???).
Anyway, on the off chance that this is what I needed I tried it, however I tried @runmode:hide since that is what other commands looked like. It didn't complain or anything, and when it had no effect I wasn't too surprised. I see you were suggesting an equal sign instead of a colon, and so of course I tried that, but again no luck.

However it seemed more and more likely that this was the correct approach, so out of desperation I tried many things and I happened to stumble on the right approach, which is to simply use a space between @runmode and hide. I think these manual writers are just cruel. Or perhaps they really don't know that all we need is one simple example and we can figure out the rest. Instead they just blather on and make us guess the important stuff.

And by the way, one more point about Leo's suggestion. He said it wouldn't work on the root folder of a drive.
He was partly correct since indeed CWD reports an error in that case, but interestingly enough it does CD
to the correct dirve anyway. Perhaps this is just a lucky fluke in the way CWD operates.

Anyway, thanks again for the suggestions.

~Paul