Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 169009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:33:16+00:00 2026-05-11T12:33:16+00:00

I am writing a batch file to execute some other programs. In this case

  • 0

I am writing a batch file to execute some other programs. In this case I need to prompt for a password. Do I have any way to mask the input text? I don’t need to print ******* characters instead of input characters. Linux’s Password prompt behavior (Print nothing while typing) is enough.

@echo off SET /P variable=Password :  echo %variable% Pause 

This will read the input but I can’t mask the text using this approach.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T12:33:17+00:00Added an answer on May 11, 2026 at 12:33 pm

    Up to XP and Server 2003, you can make use of another included tool (VBScript) – the following two scripts do the job you want.

    First, getpwd.cmd:

    @echo off <nul: set /p passwd=Password:  for /f 'delims=' %%i in ('cscript /nologo getpwd.vbs') do set passwd=%%i echo. 

    Then, getpwd.vbs:

    Set oScriptPW = CreateObject('ScriptPW.Password') strPassword = oScriptPW.GetPassword() Wscript.StdOut.WriteLine strPassword 

    The getpwd.vbs simply uses the password object to input the password from the user and then print it to standard output (the next paragraph will explain why that doesn’t show up in the terminal).

    The getpwd.cmd command script is a bit trickier but it basically works as follows.

    The effect of the '<nul: set /p passwd=Password: ' command is to output the prompt with no trailing newline character – it’s a sneaky way to emulate the 'echo -n' command from the bash shell. It sets passwd to an empty string as an irrelevant side effect and doesn’t wait for input since it’s taking its input from the nul: device.

    The 'for /f 'delims=' %%i in ('cscript /nologo getpwd.vbs') do set passwd=%%i' statement is the trickiest bit. It runs the VBScript with no Microsoft ‘advertising’, so that the only line output is the password (from the VBscript 'Wscript.StdOut.WriteLine strPassword'.

    Setting the delimiters to nothing is required to capture an entire input line with spaces, otherwise you just get the first word. The 'for ... do set ...' bit sets passwd to be the actual password output from the VBScript.

    Then we echo a blank line (to terminate the 'Password: ' line) and the password will be in the passwd environment variable after the code has run.


    Now, as mentioned, scriptpw.dll is available only up to XP/2003. In order to rectify this, you can simply copy the scriptpw.dll file from the Windows\System32 folder of an XP/2003 system to the Winnt\System32 or Windows\System32 folder on your own system. Once the DLL has been copied, you will need to register it by running:

    regsvr32 scriptpw.dll 

    To successfully register the DLL on Vista and later, you will need administrator privileges. I haven’t examined the legality of such a move so cave lector.


    If you’re not overly keen on trying to track down and register older DLL files (for convenience or legal reasons), there is another way. Later versions of Windows (the ones that don’t have the required DLL) should have Powershell available to you.

    And, in fact, you really should consider upgrading your scripts to use it fully since it’s a much more capable scripting language than cmd.exe. However, if you want to keep the bulk of your code as cmd.exe scripts (such as if you have a lot of code that you don’t want to convert), you can use the same trick.

    First, modify the cmd script so it calls Powershell rather than CScript:

    @echo off for /f 'delims=' %%i in ('powershell -file getpwd.ps1') do set passwd=%%i 

    The Powershell script is equally simple:

    $password = Read-Host 'Enter password' -AsSecureString $password = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($password) $password = [Runtime.InteropServices.Marshal]::PtrToStringAuto($password) echo $password 

    although with some marshalling to get the actual password text.

    Remember that, to run local unsigned Powershell scripts on your machine, you may need to modify the execution policy from the (draconian, though very safe) default, with something like:

    set-executionpolicy remotesigned 

    from within Powershell itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 93k
  • Answers 93k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer ThreadPoolExecutor provides beforeExecute and afterExecute methods that you can override.… May 11, 2026 at 6:34 pm
  • Editorial Team
    Editorial Team added an answer Quoting from create-table - indexes andkeys {INDEX|KEY} So KEY is… May 11, 2026 at 6:34 pm
  • Editorial Team
    Editorial Team added an answer In short, mirroring allows you to have a second server… May 11, 2026 at 6:34 pm

Related Questions

I've got a somewhat dated Java EE application running on Sun Application Server 8.1
When an ASP.NET application is running under IIS6.0 in Windows 2003 Server with impersonation,
I am writing a batch file script using Windows command and want to change
I am writing a batch script which I wish to open a file and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.