Sure, you must wait for the console window to open, set focus to the command windows, then sendkeys.

By the way, this isn't a very secure method as your password is in plain text in the body of your script.