Quantcast
Channel: Indigo Rose Software Forums - Forums
Viewing all articles
Browse latest Browse all 2105

Quotes inside String

$
0
0
Hi there,
I would like to include quotes inside a string. Not just double quotes, but single quotes inside double quotes.
My intention is to run a powershell command - something like:
get-WmiObject -Class Win32_Product -Filter "Name LIKE '%Visual C++%'"

So I can pass this in to the File.Run() command as a String parameter - but of course it needs quotes around it to make it a string. At which point, the parser sees the extra set of quotes and fails. I've tried to replace the single quotes with \' and replace the double quotes with single, but the File.Run fails.

My (failing) command is this: File.Run("powershell.exe","get-WmiObject -Class Win32_Product -Filter 'Name LIKE \'%Visual C++%\''| Out-File 'C:\\Temp\\COutput.txt' -NoNewLine -encoding ascii", "C:\\Temp", SW_SHOWNORMAL, true);

For clarity, the \'' in the above command is actually
\' followed by ',
not
"

Is there any way for me to get this to work? I could encapsulate the String into a .ps1 file and then use the filename in File.Run() command, but then I have the problem of locating that file (which won't have been installed yet).

Thanks in advance,
John

Viewing all articles
Browse latest Browse all 2105

Trending Articles