|
Post by whathim on Sept 4, 2023 17:21:01 GMT 1
Jos
I’m having trouble passing arguments to batch files. Here’s what I’m doing.
In my batch file OpenV.bat (called from Autoexec.txt) that invokes my application, I want to run a batch file under cmd.exe just before I invoke Open.exe. So, for testing purposes, OpenV.bat contains the following commands.
ECHO %1
CMD /k C:\OpenV3_2\Test123.bat %1
C:\OPENV3_2\OPEN.EXE /50 %1 %2 %3 %4
The Test123.bat file contains:
ECHO %1
ECHO “%1”
PAUSE
The argument %1 gets passed from Autoexec.txt and is dully ECHOed correctly in OpenV.bat. Yet in Test123.bat, ECHO prints %1 or “%1”. It’s as if the %1 argument is not being expanded in the CMD statement.
Am I doing something silly?
|
|
|
Post by Jos on Sept 4, 2023 17:55:09 GMT 1
|
|
|
Post by whathim on Sept 4, 2023 20:57:51 GMT 1
Thanks Jos.
Re. Martin’s workaround, I haven’t got command.com on my system – I just get “Bad command or file name”. Am I misunderstanding?
|
|
|
Post by Jos on Sept 4, 2023 21:10:17 GMT 1
command.com should always appear to be present inside vDos, for instance: Jos
|
|
|
Post by whathim on Sept 4, 2023 22:06:45 GMT 1
I’ve just tested “dir command.com” which does indeed show command.com is visible inside vDos, exactly as your screen shot. But when I try to invoke it, I just get “Bad command or file name”. I’ve tried several ways.
Command.com [/c CMD]
C:\command.com [/c CMD]
C:\vDos\command.com [/c CMD]
All give “Bad command or file name”.
|
|
|
Post by Jos on Sept 5, 2023 7:56:53 GMT 1
Surely there was never attention to start a further command processor by a command line.
I’ll have a look to support that, even as it’s not logical.
Except now for passing on variables.
I managed at first to do command.com… But then noticed an actual command.com file in the directory. You could also create a dummy command.com file, so it’s found. Mind, .COM files are just memory images. The actual command.com seems to be executed if a file path is specified.
Jos
|
|
|
Post by whathim on Sept 5, 2023 10:16:04 GMT 1
I’d be interested to know how Martin’s workaround is working – I can’t get it to work anyway I try.
Never mind – I will await what you come up with regarding passing variables to CMD. Many thanks for the help.
|
|
|
Post by martin on Sept 5, 2023 16:18:09 GMT 1
As Jos said, my workaround only works, if there's a dummy command.com in (vdos) C:\. Just create a textfile with windows notepad, mine only contains the word "Dummyfile", copy it to the directory, which is vdos C:\ and rename the copy to command.com.
I had forgotten about that. The file originally was used to make a "Go to DOS Shell" menu option work in a dos program and an older vdos-version. It seems that p.e. FreeEDIT don't need that in the current vdos-Version (for "Go to DOS Shell").
HTH
Martin
|
|
|
Post by whathim on Sept 5, 2023 21:26:57 GMT 1
Thanks for replying, Martin. Nope, already tried the dummy file and I get: In detail, what I do: 1. Create text file in (Windows) C:\vDos\ folder (where vDos.exe resides) and rename it to command.com 2. In my OpenV.bat file (the batch that runs my Open.exe application) I try the following commands: C:\command.com /c CMD /k C:\OpenV3_2\Test123.bat %1 Results in “Bad command or file name”. C:\vDos\command.com /c CMD /k C:\OpenV3_2\Test123.bat %1 Results in vDos exception (see screenshot). Note that in my Autoexec.txt I have USE C: C:\ which means that (vDos) C:\ is the same as (Windows) C:\ (yes, I know Jos doesn’t like this). So, it is hardly surprising I get “Bad command or file name” when I issue the command starting with “C:\command.com /c …”. So, the other thing to try would be to place the dummy command.com in my vDos C:\ = Windows C:\ root. I’m a bit wary of doing that so, as I said previously, I’ll await any updates. Many thanks anyway.
|
|
|
Post by martin on Sept 5, 2023 22:20:28 GMT 1
There's a second workaround (without command.com) using the ECHO command and a temporary batch file. In your OpenV.bat above, replace the line
CMD /k C:\OpenV3_2\Test123.bat %1
by the two lines
ECHO CMD /k C:\OpenV3_2\Test123.bat %1 > temp.bat call temp.bat
This creates (in vdos) a temporary batchfile (temp.bat) with a substituted %1 variable and executes temp.bat.
|
|
|
Post by whathim on Sept 5, 2023 22:47:42 GMT 1
I do believe it’s worked, although I had to specify full path for temp.bat.
That’s brilliant – I can now continue playing.
Many thanks
|
|