primosad
primosad

Reputation: 53

How to hide a password in a .bat file?

I'd like help in setting password in a batch file but without exposing password.

If I SET password="abc123", I don't want abc123 to be visible in the batch file, as other people will be running the .bat file.

Upvotes: 4

Views: 10236

Answers (2)

SachaDee
SachaDee

Reputation: 9545

There is unfortunately no good solution to hide a password in batch

Even if you crypt it, change it to HEX, hide it in an Alternative Data Stream (ADS) or whatever you want.

At a moment you have to test the value in your code with an IF test.

At this point the password, crypted or not, will be visible or settedin a variable that can be echoed.

You can also compress your BAT in a self-extracting .EXE, but this is very easy to crack, while the .BAT file have to be decompressed before you run it (in the %temp% folder).

So there is no way to really hide a password in a .BAT file

Upvotes: 3

Hackoo
Hackoo

Reputation: 18827

You can try this method : Password hidden using ADS

  1. create and save your batch file
  2. use the ECHO command to 'place' your password into an ADS attached to your batch file
  3. use redirection to read the password from the ADS (Alternative Data Stream) file

Upvotes: 1

Related Questions