Reputation: 1405
I have a number of bat files in my drive, On a monthly basis I want to update the bat files with new username and passwords replacing the old credentials in each of the bat files. For now each bat file is opened and the credentials are manually updated.
Is there is way I can update the bat files with passwords at once?
Upvotes: 0
Views: 1499
Reputation: 41257
In pw.bat you can have
@echo off
set "user=myname"
set "pw=apple"
and in every other batch file that needs the credentials you start it with
@echo off
call pw.bat
and you can use the %user%
and %pw%
variables in your batch files, and maintain just the one file with the username and password.
Upvotes: 1
Reputation: 56208
How do you like the idea to edit a single file instead of all those batches?
Edit your batchfiles (a last time) and include this code:
(
set /p user=
set /p pwd=
)<credentials.txt
echo %user% %pwd%
That will take user
and password
from a file (credentials.txt
)
credentials.txt
will have two lines only. First line is username
, 2nd line is password
:
testuser
secretword
In Future, you will only have to maintain this little file.
Upvotes: 0