0

I'm using digiKeyboard library to type to a powershell, but I need to type a backslash (a lot of them), but I can't figure it out.

I have been looking for the solution for about 3 hours and I still can't find it. Please let me know how to make a backslash work.

The powershell command that I want to execute:

cmd /C "start /MIN powershell iwr -Uri https://tinyurl.com/WjnAU6 -OutFile c:\windows\temp\b.jpg;sp 'HKCU:Control Panel\Desktop' WallPaper 'c:\windows\temp\b.jpg';$a=1;do{RUNDLL32.EXE USER32.DLL,UpdatePerUserSystemParameters ,1 ,True;sleep 1}while($a++-le59)"

It just changes the wallpaper with a downloaded image, try in on your friend.

Michel Keijzers
  • 12,954
  • 7
  • 40
  • 56
Burgerl X
  • 3
  • 3

1 Answers1

0

To include \ in a string so it can be printed you have to escape it. \ is itself the escape character, so doubling it up "escapes the escape character" so it is interpreted as a normal character.

So to print "c:\windows" you would actually have to type "c:\\windows" and the \\ gets changed by the compiler into just \

Majenko
  • 105,095
  • 5
  • 79
  • 137