Securing Batch scripts

When using credentials in batch scripts, anyone who has access to the script can access the credentials. Instead you can store the credentials in a seperate file (which only the user executing the batch script can access) and use these in the script. Here’s how to do this …

First create a text file containing the credentials (in this example vault.txt).

Add these lines to your batch script :

for /f “delims=” %%x in (c:\scripts\vault.txt) do set Vault=%%x
net use x: \servername\share /user:username %Vault%

The first line puts the password in the variable and in the second line the variable is added to the command.

Visitor Score
[Total: 0 Average: 0]