windows - Calling PowerShell from a batch file fails -
when call following command command line, works well. when put in .bat file , call file, syntax error saying i'm missing closing ' @ end of command.
powershell -command "& 'c:\program files\tortoisesvn\bin\svn.exe' status | ? { $_ -match '^!\s+(.*)' } | % { & 'c:\program files\tortoisesvn\bin\svn.exe' rm $matches[1] }" a strange thing happens when call .bat command gets mysteriously changed. output of .bat file:
c:\workspace>powershell -command "& 'c:\program files\tortoisesvn\bin\svn.exe' status | ? { $ _ -match '^!\s+(.*)' } | \program files\tortoisesvn\bin\svn.exe' rm $matches[1] }" string missing terminator: '. + categoryinfo : parsererror: (:) [], parentcontainserrorrecordexception + fullyqualifiederrorid : terminatorexpectedatendofstring i'm 100% sure content of .bat file , command run manually same , editor (notepad++) not perform stupid thing breaking command in 2 lines.
what doing wrong?
character % anywhere in string must escaped 1 more % in batch file interpreted literal character.
powershell -command "& 'c:\program files\tortoisesvn\bin\svn.exe' status | ? { $_ -match '^!\s+(.*)' } | %% { & 'c:\program files\tortoisesvn\bin\svn.exe' rm $matches[1] }" works in batch file. enter in command prompt window help for or for /? , can read requirement escaping % on first page output.
Comments
Post a Comment