I'm not sure what using Runas or RunnAs has to do with passing a password to a function (it could be a database or application password), but there is an issue with Mart's reference to RunAs.
Windows RunAs (one "N") will not work for unattended scripted solutions, as you cannot specify the password on the command line. Shawn's RunnAs does allow the password to be specified, and can encode the credentials into the task. It's an excellent (and free) method for running scripts as a specific user. Don't overlook the task scheduler, either, since you can control it remotely and specify the account to run as.
Mart's references are all appropriate for running scripts in an specific Windows or AD account environment. Just keep the RunAs limitation in mind, as it will prompt the user for the password.
The CoDec UDF provides a high level of obfuscation, and there's a ROT13 UDF that provides very simple and widely used obfuscation of alpha characters. Keep in mind that Obfuscation is not encryption. It's usually enough for scripts, especially when combined with appropriate account access (ie - not Domain or Enterprise admin account access!)
Glenn
_________________________
Actually I
am a Rocket Scientist!