The problem was caused by a space in their Windows account name. When dealing with spaces in file/directory names in the command prompt, you have to wrap them in quotes. However, since the code uses an environment variable "%appdata%" this was not possible. Therefore, to fix the problem you have to replace the environment variable with a direct path and wrap it in quotes.
I am not sure why the space was causing an issue when using an environment variable though. I would have assumed using it would have bypassed the space issue but it did not.
So if you ever get an error saying unrecognized command when using this script, that's most likely the problem.