My string looks something like this:
runprog.exe –a –f “C:\My Folder\filename.txtâ€
send string to Command Prompt window with embeded quotes
Moderators: JRL, Dorian (MJT support)
I understand the issue.
The issue is in passing a parameter to a compiled exe.
The CMD shell is designed to strip double quotes.
So do this:
C:\>mytest /mystring="'hello there'"
Put the string/path/whatever inside of single quotes, and wrapped with double quotes on the outside.
Then inside the Macro Scheduler program do a replace on single quotes and change to double quotes.
The issue is in passing a parameter to a compiled exe.
The CMD shell is designed to strip double quotes.
So do this:
C:\>mytest /mystring="'hello there'"
Put the string/path/whatever inside of single quotes, and wrapped with double quotes on the outside.
Then inside the Macro Scheduler program do a replace on single quotes and change to double quotes.
Another method is to "URL Encode" the string
and then unencode the string inside Macro Scheduler.
Like this:
And then the command line would be passed like this
C:\>mytest /MYSTRING=%22hello%20there%22
and then unencode the string inside Macro Scheduler.
Like this:
Code: Select all
VBStart
VBEnd
VBEval>unescape("%mystring%"),mystring
MessageModal>mystring
And then the command line would be passed like this
C:\>mytest /MYSTRING=%22hello%20there%22
Thanks to adroege for a very good suggestion.
In my application I need to send text to the Console window that has very long and complex strings. These contain embedded spaces and also embedded double quotes.
I made the adroedge example into a full macro then complied it into MyCommand.EXE.
Here is a possible usage in VisualBasic, this in a loop.
dim instring , outstring, commandstring as string
commandstring = "C:\Test Files\My Run.BAT"
instring = "testprog.exe -f=""" & commandstring & """"
outstring = urlencode(instring)
call waitforshell("C:\MyCommand.exe /mystring=" & outstring,1)
testprog.exe is any EXE or BAT program that can run in the Command shell, and requires command-line arguments
note the triple quotes for instring, this is one way to embed double quotes inside a string in VBA. In my code, the value of commandstring changes.
/mystring= is the way to pass the encoded string through to MacroScheduler as argument named "mystring"
urlencode and waitforshell can be found on the web.
In my application I need to send text to the Console window that has very long and complex strings. These contain embedded spaces and also embedded double quotes.
I made the adroedge example into a full macro then complied it into MyCommand.EXE.
Here is a possible usage in VisualBasic, this in a loop.
dim instring , outstring, commandstring as string
commandstring = "C:\Test Files\My Run.BAT"
instring = "testprog.exe -f=""" & commandstring & """"
outstring = urlencode(instring)
call waitforshell("C:\MyCommand.exe /mystring=" & outstring,1)
testprog.exe is any EXE or BAT program that can run in the Command shell, and requires command-line arguments
note the triple quotes for instring, this is one way to embed double quotes inside a string in VBA. In my code, the value of commandstring changes.
/mystring= is the way to pass the encoded string through to MacroScheduler as argument named "mystring"
urlencode and waitforshell can be found on the web.
gpapp