I have a script comprising of batch files that generate powershell scripts. I've taken it upon myself to accomplish the same task via VB Script. So far I've assigned most of the info I need to strings. But I would like to have a prompt for a password that is stored as a secure string and can be outputted to a text file for later use in further scripts. So far the only code I've found doesn't work I think perhaps because it was intended for VB rather than VBS. Any help greatly appreciated.
The powershell code previously used was.
echo Please enter admin credentials (This will be stored in a secure string:
powershell -Command "& { read-host -assecurestring | convertfrom- securestring | out-file C:\S3BS\reports\input.txt; } "
If you are executing the VBScript via
cscript.exe
something like;You can use the
WScript
object to access theStdIn
(for input) andStdOut
(for output) streams to the command window using a script like this;Output:
You can adapt it to prompt for passwords but be aware that the input is not hidden so all the characters typed are visible in the command window until it's closed.
I think this function PasswordBox can help you, just give a try ;)
You can use this small code with powershell and batch