TCC: No closing quote

Nov 3, 2012
27
0
Hi guys, I'm having a problem with the following command:

PowerShell "Add-Type -TypeDefinition """"using System;`n using System.Runtime.InteropServices;`n public class PInvoke { [DllImport(`"""user32.dll`""")] public static extern bool SetSysColors(int cElements, int[] lpaElements, int[] lpaRgbValues); }""""; [PInvoke]::SetSysColors(1, @(1), @(0x000000))" >NUL

Under CMD Prompt it works without error, while in TCC it gives the error "no closing quote".

Have you any idea? Thank you!
 

rconn

Administrator
Staff member
May 14, 2008
10,988
98
TCC is actually parsing that line correctly, given that the single backquote character is syntactically significant in TCC. (It works in CMD because CMD ignores back quotes.)

Although you have a matching number of double quotes and back quotes, the first three back quotes are embedded in a double-quoted argument (everything up to the quotes before "user32.dll"). There is a single back quote following user32.dll, which is what generates the "no closing quote" error.

You could work around it by disabling quote processing in TCC (via SETDOS /X7), though I'd be inclined to make that an alias specific to Powershell commands.