2

I now have emacs running under VcXsrv started when I open WSL (Unbuntu) on Windows 10. And if I invoke "shell" it runs a bash shell fine. However, I have a few command files I like to run. In particular, I want to run the windows studio command line tools in a dos like environment, so first run "c:\program files (x86)\microsoft visual studion...\vsvars.bat" then run my "xyzzy.cmd" script that invokes nmake to build and run a legacy test program.

I tried running both directly from bash and they don't work (no surprise). Then I tried invoking c:\windows...\cmd.exe as my shell interpreter in emacs but that doesn't seem to bring up a prompt. It just hangs the shell. I also tried the "cmdproxy.exe" which you use with emacs running directly on windows and that did no better.

Currently, I am running one emacs directly on windows (and when I invoke shell there it brings up command (using cmdproxy.exe) if I understand right). In that I can run the scripts and that emacs will capture the output in a buffer, which I can then write to a file. And I have the separate emacs I described above to do my real editing, and I read the file in there. I'd rather have just one emacs, so I could use the emacs functions for switching buffers etc.

(By the way, I think I could do it under cygwin, but I'd rather use WSL.)

Here's what happens if I open a shell window in emacs and type the path to cmd.exe in it ($ is my shell prompt):

$ ls -l  /mnt/c/Windows/System32/cmd.exe
-r-xr-xr-x 2 cfclark cfclark 280064 Oct 28 23:03 /mnt/c/Windows/System32/cmd.exe
$ /mnt/c/Windows/System32/cmd.exe /?
[6n

At that point the shell is hung.

But you answer gave me an idea and I am closer:

$ /mnt/c/Windows/System32/cmd.exe /C z:/testbase/cpandrun.cmd -next -rev24 | cat
The system cannot find the path specified.
 +----------------------------------------------------------------------
  Setting up environment vars to build the tutorials with MVC++ 2019
 +----------------------------------------------------------------------
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\cfclark\AppData\Roaming
...  (lots of environment variables omitted)
The system cannot find the path specified.
yxx1.exe does not exist
Too many of the files: yxx.exe and yxxdiff.cmd 
         or yxx1.exe, yxx2.exe, and yxx.cmd.cmd
are missing from \yxx.24\bin.
The system cannot find the file specified.
The system cannot find the path specified.
Done!
The system cannot find the path specified.
Done!

The .cmd file expected to be run from a joined directory, so that it looks like the root of a partition, but that I can probably fix in the .cmd script.

1
  • Type cmd /?. Also call /? for your next problem. You have to call both of your commands in the same process. So put call vcvars.bat into the other file.
    – Mark
    Commented Mar 9, 2020 at 22:05

1 Answer 1

1

To get this work from inside emacs (inside wsl), you need to add "| cat" to the line:

/mnt/c/Windows/System32/cmd.exe /c path_to_run.cmd | cat

This gets the output displayed in the emacs shell buffer and it will even wait for input that you type in the buffer. At least it did for the "pause" command in my .cmd file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .