15

I've been searching for a solution to this but couldn't find one. Not sure if its possible.

Can I pass into command-line execution that passes a in a bat file which has an input file as its arguments?

So from the command-line it'll look like this:

C:\run.exe "C:\space folder\run.bat "C:\space folder\input.txt""

The problem is with the folders that has spaces so the quotes are required to be in there.

informatik01
  • 16,038
  • 10
  • 74
  • 104
user2617566
  • 201
  • 1
  • 2
  • 7

3 Answers3

16

Try this:

C:\run.exe "C:\space folder\run.bat \"C:\space folder\input.txt\""

And here is a link that you can see all escape characters http://www.robvanderwoude.com/escapechars.php

Jorge Campos
  • 22,647
  • 7
  • 56
  • 87
1

I know it's an old topic, but I found the answer and would like to share.

In Windows you don't have to escape the quotes. Just use them normally.

In this case:

C:\run.exe ""C:\space folder\run.bat" "C:\space folder\input.txt""

Rafa Jaques
  • 115
  • 7
  • 4
    Are you sure? I made a simple run.bat file with two lines "echo %1" and "echo %2". Then I passed in your suggested string as argument. The first parameter %1 was shown to be ""C:\space and the second was shown to be folder\run.bat" "C:\space – Tormod Oct 21 '16 at 18:40
  • echo may be a special case since it's not really disk-based command, but a built-in one. It may just output everything after it. – Cthutu Jan 04 '19 at 13:25
  • The problem is that there are two different ways to receive command lines, `GetCommandLine()` or `main(int, char**)`. `echo "Hello"` prints quotes while the same received as `args[]` has no quotes. – Renate Jan 09 '23 at 12:03
1

In the end, all I needed was quotes.

winrs -r:MACHINE001 ""C:\Program Files\MyApp\My App.exe" -x "LOTS OF PARAMETERS""
Adriaan
  • 17,741
  • 7
  • 42
  • 75
JRH
  • 11
  • 1