In my answer I gave you the way to securely store the credential. In the link I provided in that answer there was also a way to create the credential if it hasn't been created beforehand.
You can place the user and password into a file for a one-time use and modify the way that the values are acquired. Let's say you placed both the user and password into one text file. The code in your script would read those files, use the user/password to create and store the credential, and then delete the file(s) that held the plain-text user id and password.
From then on, the scheduled task would find the credential in the XML file. If you want to change the user id, or the password, delete the XML file holding the credential and create a new file for the user id and password. The next time the scheduled task runs it will remove those plain-text files and store the new credential in the XML file.
The user/password is exposed only for a brief time (and if it/they are properly secured only a very few people would have access to it/them). It's not an absolutely secure method, but it will reduce your exposure by quite a lot.