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 8330015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:59:06+00:00 2026-06-09T01:59:06+00:00

I am running a batch script and somewhere the user has to access a

  • 0

I am running a batch script and somewhere the user has to access a database.

At this moment, a window made in vbscript would prompt asking the user to type in the login and password. (OK, Cancel buttons)

If the credentials are correct after the OK, the batch would continue according to planA, otherwise the batch would do something else going to planB. If (Cancel), it would return to the batch and the main menu.

THIS IS WHAT I HAVE BEEN STRUGGLING WITH:

@echo off 

:Ini 
echo   [1] Access database 
echo   [2] Main menu 
echo: 
set /p Quest= What do you prefer (1 / 2)?        
if not '%Quest%'=='' set Quest=%Quest:~0,1%  
if '%Quest%'=='1' goto VBS 
if '%Quest%'=='2' goto BATCH 
echo Invalid option, please try again 
cls 
goto Ini 

:BATCH 
echo Heading for main menu ... 
goto Main 

:VBS 
:wscript.echo InputBox("Enter your password","VBScript-Batch") 
findstr "^:" "%~sf0" | findstr /i /v ":Label" >temp.vbs 
for /f "delims=" %%N in ('cscript //nologo temp.vbs') do set pass=%%N  
del temp.vbs 

:Label1 

If %pass%=="okay" echo Valid Password ! & goto PLAN-A
If not %pass%=="okay" echo Invalid Password !! & goto PLAN-B 

:PLAN-A
echo continue from here 

:PLAN-B
echo do something else

(…)

— How to capture the user information, validate it and go back to the batch for the planA or planB ??

As you see, if we eliminate the “& goto PLAN” stuff the script works. It sends the VBS input “pass” to the batch and the batch echoes “continue from here” or “do something else”, from where the rest of your code should continue in the same batch.

However, it is not working … Any help to make this really work ?

  • 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. Editorial Team
    Editorial Team
    2026-06-09T01:59:09+00:00Added an answer on June 9, 2026 at 1:59 am

    Your primary issue was you didn’t set up the file properly to facilitate extracting the VBS from the batch file. Your VBS looks no different than a batch label. You filter out “Label” labels, but you still include lines like :ini, :BATCH, etc. Obviously those will trip up VBS. I solved the problem by prefixing your VBS with ::: and adapting your filter. There is no need to explicitly filter out any labels. I chose 3 colons because a single colon is used for a label, and 2 colons is frequently used for comments. You could have multiple independent VBS scripts embedded within your batch simply by varying the number of preceding colons.

    I also restructured the code a small amount, and sprinkled in some EXIT /B statements so that code does not fall through. Also your :MAIN is not defined so I commented out the GOTO and replaced it with EXIT /B.

    @echo off
    :Ini
    echo   [1] Access database
    echo   [2] Main menu
    echo:
    set /p Quest= What do you prefer (1 / 2)?
    if not '%Quest%'=='' set Quest=%Quest:~0,1%
    if '%Quest%'=='1' goto VBS
    if '%Quest%'=='2' goto BATCH
    echo Invalid option, please try again
    cls
    goto Ini
    
    :BATCH
    echo Heading for main menu ...
    ::goto Main
    exit /b
    
    :VBS
    :::wscript.echo InputBox("Enter your password","VBScript-Batch")
    findstr "^:::" "%~sf0" >temp.vbs
    for /f "delims=" %%N in ('cscript //nologo temp.vbs') do set pass=%%N
    del temp.vbs
    If "%pass%"=="okay" (
      echo Valid Password !
        goto PLAN-A
    ) else (
      echo Invalid Password !!
        goto PLAN-B
    )
    
    :PLAN-A
    echo continue from here
    exit /b
    
    :PLAN-B
    echo do something else
    exit /b
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made this batch script which will allow the user to enter a
I have a script running a batch of very similar queries. All of them,
I am running a batch job that has been going for many many hours,
How to hide cmd window while running a batch file? I use the following
I'm running this small C# test program launched from a pre-commit batch file private
I'm running a script from the command line via R CMD BATCH script.in.R script.out.R
I am running Symfony 1.3.2 on Ubuntu. I need to write a batch script
Im running a batch script in windows which will Perform some compilation and make
Why is batch not running this second for loop? What am i doing wrong?
When running a batch import script in Python (openblock), I'm getting the following invalid

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.