How escape a pipe ?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
einstein1969
Expert
Posts: 776
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

How escape a pipe ?

#1 Post by einstein1969 » 18 Jun 2020 15:34

Hi to all,

I have a problem with this code

Code: Select all

for /f "delims=" %I in ('mshta "about:<OBJECT id=HTMLDlgHelper classid="CLSID:3050F4E1-98B5-11CF-BB82-00AA00BDCE0B"></OBJECT><SCRIPT language="VBSCRIPT">Sub window_onload : a=HtmlDlgHelper.object.openfiledlg("C:\windows.iso", ,"*.iso|","Select"): CreateObject("Scripting.FileSystemObject").GetStandardStream(1).WriteLine a : msgbox a : close : end sub</SCRIPT>"') do @echo %I
I need to escape the pipe in the part "*.iso|". I have tried with a classic caret ^ but not work for me.

-

miskox
Posts: 349
Joined: 28 Jun 2010 03:46

Re: How escape a pipe ?

#2 Post by miskox » 19 Jun 2020 01:56

Does it work If you add ^ ?

Code: Select all

for /f "delims=" %I in ('mshta "about:<OBJECT id=HTMLDlgHelper classid="CLSID:3050F4E1-98B5-11CF-BB82-00AA00BDCE0B"></OBJECT><SCRIPT language="VBSCRIPT">Sub window_onload : a=HtmlDlgHelper.object.openfiledlg("C:\windows.iso", ,"*.iso^|","Select"): CreateObject("Scripting.FileSystemObject").GetStandardStream(1).WriteLine a : msgbox a : close : end sub</SCRIPT>"') do @echo %I
Saso

T3RRY
Posts: 40
Joined: 06 May 2020 10:14

Re: How escape a pipe ?

#3 Post by T3RRY » 19 Jun 2020 03:41

I can't test in full if it's the intended outcome, however an additional escaping of the pipe prevents the syntax error.
So ^^^| as opposed to ^|

Code: Select all

for /f "delims=" %I in ('mshta "about:<OBJECT id=HTMLDlgHelper classid="CLSID:3050F4E1-98B5-11CF-BB82-00AA00BDCE0B"></OBJECT><SCRIPT language="VBSCRIPT">Sub window_onload : a=HtmlDlgHelper.object.openfiledlg("C:\windows.iso", ,"*.iso^^^|","Select"): CreateObject("Scripting.FileSystemObject").GetStandardStream(1).WriteLine a : msgbox a : close : end sub</SCRIPT>"') do @echo/"%I"

einstein1969
Expert
Posts: 776
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: How escape a pipe ?

#4 Post by einstein1969 » 19 Jun 2020 13:29

ok
the triple caret ^^^ work well.

Thank you, guy!

Post Reply