# Batch to read password from txt file



## dampyr (Nov 25, 2011)

I have username and password in txt file-one string.I have batch that run application that require username and password.I want that batch supply username/password from txt file,in variable form:

sqlplus "username/password" -argument

So i want that instead "username/password" put variable which will read data from txt file:

sqlplus @variable -argument.

I need this because we need to change password every month,and because we need to run more instances of this app (every have it's own batch),i want to change password only once in txt file,not in every batch files

Thanks in advance


----------



## Squashman (Apr 4, 2003)

set /p userpass=<passwordfile.txt


----------



## dampyr (Nov 25, 2011)

Thanks for quick replay:
so complete code will be:



set /p userpass=<passwordfile.txt
sqlplus userpass -argument
right?


----------



## Squashman (Apr 4, 2003)

I know nothing about SQL. 
If your username and password are on one line in a text file, the code above will put that into a variable with a batch file.

```
C:\Users\Squash>type passwordfile.txt
myuser/mypass

C:\Users\Squash>set /p userpass=<passwordfile.txt

C:\Users\Squash>echo %userpass%
myuser/mypass

C:\Users\Squash>
```


----------



## dampyr (Nov 25, 2011)

Thanks again,yes my username and password are in format username/password,that is whole content of txt file,in single line


----------

