Can a batch file pause to enter a password?


  1. Posts : 22
    Windows 7, 64-bit
       #1

    Can a batch file pause to enter a password?


    I use Windows 7 Pro.

    I have made a batch file to quickly back up certain files.

    If I need to encrypt a backed-up file, I use WinZip to compress and encrypt it.

    To encrypt, WinZip requires that you manually specify a password. This password must be entered repeatedly throughout the batch file. I'd like the batch file to pause the first time, wait for me to enter the password, then proceed, automatically entering that password whenever it is requested again.

    Can this be done?

    PS: I used to specify the password in the batch file itself, but that's not very secure. Anyone viewing the batch file could discern the password.
      My Computer


  2. Posts : 6,458
    x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
       #2

    Yes

    set /p variable= [string]

    set /p secretword= Enter the secret word and win 100 dollars

    Note there is a space before the prompt string, but no space after the variable
    Then you can use the variable %secretword% throughout your bat file.
      My Computer


  3. Posts : 22
    Windows 7, 64-bit
    Thread Starter
       #3

    It works fine


    Many, many thanks.
      My Computer


  4. Posts : 6,458
    x64 (6.3.9600) Win8.1 Pro & soon dual boot x64 (6.1.7601) Win7_SP1 HomePrem
       #4

    Glad to have helped and thank you for marking your thread solved.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 08:06.
Find Us