0

I have a *.cmd to be called by texstudio to which I pass two arguemtns: tex file name (%) and the engine (lualatex)

In texstudio, when I try to execute the cmd file by defining the user command by

cmd.exe /C "C:\Users\Diaa\Desktop\New folder\BuildExamV2.cmd" % lualatex

enter image description here

I end up with the following error

C:\Users\Diaa\Desktop\New' is not recognized as an internal or external command, operable program or batch file.

However, without passing the arguments (i.e. by omitting % lualatex from the definition), the cmd file is executed properly without issues.

So, how to call it properly in texstudio with passing the arguments % lualatex?

Diaa
  • 135
  • 1
  • 10
  • The command structure is this `%SystemRoot%\System32\cmd.exe /D /C "command or commands and/or arguments passed to the executable"`. The command you are wanting to pass includes spaces, and should therefore be double-quoted. It should therefore look more like this: `%SystemRoot%\System32\cmd.exe /D /C ""C:\Users\Diaa\OneDrive [rest of the absolute path to the command with spaces]""`. That will correctly run cmd.exe with its appropriate parameters, beyond that you will have to consider whether any of the characters used require escaping as arguments sent via textstudio. – Compo Feb 01 '22 at 18:23
  • 1
    Please provide everything without omission, by [edit]ing your question; otherwise delete your question. As it currently stands, it is unanswerable. Either way, it should essentially still use the same kind of structure, we've already indicated, example: `C:\Windows\System32\cmd.exe /D /C ""C:\Users\Diaa\OneDrive [rest of the absolute path to the command with spaces]" UnquotedARG "QuotedARG""`. – Compo Feb 01 '22 at 18:37
  • Additionally are you sure, if your executable file, _(located within your space inclusive OneDrive location)_, is a batch file, i.e. '*.cmd', that you need to specifically run it as an argument to `cmd.exe`? Have you tried using the `.cmd` file itself as the executable instead? – Compo Feb 01 '22 at 18:45
  • 1
    Diaa, your update does not follow the advice I've already provided, at the very least you should have tried it as `cmd.exe /C ""C:\Users\Diaa\Desktop\New folder\BuildExamV2.cmd" % lualatex"`. Please do not ignore advice, then expect others to continue to assist. _Also please be more careful with your tagging; the comment thread, when you posted your most recent comment, contained no advice from Mofi, only me!_ – Compo Feb 01 '22 at 18:49
  • @Compo I apologize for overlooking your detailed comment. I tried every combination of using the full path of `cmd.exe`, using `/D` and/or quoting the passed arguments, however, they all don't work. I end up with `C:\Users\Diaa\Desktop\New' is not recognized as an internal or external command, operable program or batch file.` – Diaa Feb 01 '22 at 18:57
  • Create a batch file named `test.cmd` and place it in `"C:\Users\Diaa\Desktop\New folder"`, make its content only this, `@Echo({%*}`. Now run the following command `C:\Windows\System32\cmd.exe /D /K ""C:\Users\Diaa\Desktop\New folder\test.cmd" % lualatex"`. Now run it in the same way as you have been testing with `BuildExamV2.cmd` and tell us exactly what you see. – Compo Feb 01 '22 at 19:01
  • @Compo I run it on `my document.tex` and got this output in the texstudio terminal: `Process started: C:\Windows\System32\cmd.exe /D /K ""C:\Users\Diaa\Desktop\New folder\test.cmd" "my document" lualatex"` `C:\Users\Diaa\Desktop\New' is not recognized as an internal or external command, operable program or batch file. C:\Users\Diaa\Desktop>` – Diaa Feb 01 '22 at 19:14

0 Answers0