Page 1 of 1

Reading Passwords Into a .cmd script

Posted: 02 Oct 2018 03:40
by Dosage
Hi,

I have a drive-mapping script, mapping.cmd, that uses different accounts to map different drives.
Some of the account passwords have special characters in them like % which would be parsed incorrectly if entered straight into the mapping.cmd file.
So I've put the password containing the % character into a separate file, pwd.txt, and this imports in fine when called like this:

Code: Select all

net use p: \\[some path] /user:[some domain]\[some ID] < pwd.txt
So far so good. This works and maps the drive using the password with the % in it, from pwd.txt

Just wondering, if I wanted to map another drive in mapping.cmd, which again uses a special character, if I can in some way list multiple passwords in the same pwd.txt file, rather than the clunkier method of using yet another file, say pwd2.txt, just to hold this other password e.g.

Code: Select all

net use p: \\[some path] /user:[some domain]\[some ID] < pwd.txt
net use q: \\[some path] /user:[some domain]\[some ID] < pwd2.txt
If this is possible - How would I infer the delimit between different passwords in the pwd.txt file and/or refer to them separately in the < pwd.txt part?

Or should I just use the clunky method?

Re: Reading Passwords Into a .cmd script

Posted: 04 Oct 2018 19:58
by carlos
Can you try this, is only a idea that myabe can work:

Put on a single file the password in order of mapping:

pass.txt

Code: Select all

abcd
efgh
and process.cmd

Code: Select all

(
net use p: \\[some path] /user:[some domain]\[some ID]
net use q: \\[some path] /user:[some domain]\[some ID]
) < pass.txt