Go Premium for a chance to win a PS4. Enter to Win


select variable

Posted on 2006-06-20
Medium Priority
Last Modified: 2012-05-05
ok so i have this really rought script to reset a password.

SET username=myusername
SET password=mypassword
SET file1=svn-auth-file1
SET file2=svn-auth-file2
"D:\Program Files\Apache Group\Apache2\bin\htpasswd.exe" -b "D:\Program Files\Apache Group\Apache2\etc\%file?%"  %username% %password%

What i want to do is to have the command window to pause and promt for the user to add the username then the passowrd and the to select the file (one or two).

Question by:willa666
  • 6
  • 3
  • 2
  • +1
LVL 21

Accepted Solution

alainbryden earned 2000 total points
ID: 16943422
So do you want the form as follows?

ResetPass "userName" "oldPassword" "newPassword" "newPasswordCheck"

and then you would like it to execute the above command from within the program? If that's what you would like let me know and I reserve the right to come up with the answer first :)

LVL 17

Expert Comment

ID: 16943476
Dim sUser As String
Dim sPW as String

sUser = InputBox("Enter User Name")
sPW = InputBox("Enter Password")


PID = Shell("""D:\Program Files\Apache Group\Apache2\bin\htpasswd.exe"" -b ""D:\Program Files\Apache Group\Apache2\etc\%file?%"" " + sUser+" "+sPW,vbNormalFocus)

LVL 17

Expert Comment

ID: 16943490
Did not ask for the file name but you get the idea.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.


Author Comment

ID: 16943512
Sorry forgot to add the main thing, This is a script that will run in a command windows.

I want the script to be run like follows

select a fiel to use (type 1 or 2)
promt for the username
promt for the password to reset the user account with.
LVL 17

Expert Comment

ID: 16943847
Simple way is to generate a batch file

Open "C:\tmp.bat" for output as #1
Print #1,"........."
Close #1
OK = Shell("c:\tmp.bat", vbNormalFocus)
LVL 30

Expert Comment

ID: 16948015
hmmmm this actually has nothing to do with visual basic. If you ask this in the OS / DOS section you'll have an answer in five seconds.
LVL 21

Expert Comment

ID: 16948121
no this can 100% be done in visual basic. VB's main() sub can take command prompt parameters just like C, Java, or any other language. I'm just not familiar with how you manipulate these and I'm not interested in doing the research at the moment.
LVL 30

Expert Comment

ID: 16948660
It certainly can be done 100% in visual basic.

But willa666 's request is written in a batch file and they are asking for a prompt in the command window, so I assume they want to remain on that platform.

LVL 17

Expert Comment

ID: 16949105
DOS Batch files have been replaced by Script files.  Using a script you get user imput and then use it.  The problem with script files is that some Anti-virus products block the use of scripting. If you can code in VB then the answer is so simple and it works with all anti-virus products. So if you have VB suggest you use it. If you do not have VB then you can do what you want with VBS.

Here is some info on how to create a VBS file.


And here is the script that will do as you wish.
1) Create a blank text file, paste the following code into the file.
2) The rename the file as you wish but end with .vbs.
3) Double click on the file or use as anyother comamnd.

Option Explicit
Dim objShell
Dim sFile
Dim sUser
Dim sPW
Dim sCmd

' Get user input

sUser = InputBox("Enter User Name")
sPW = InputBox("Enter Password")
sFile = InputBox("Enter file (1 or 2)")
' Create command line

sCMD ="""D:\Program Files\Apache Group\Apache2\bin\htpasswd.exe"" -b "
sCMD = sCMD & """D:\Program Files\Apache Group\Apache2\etc\svn-auth-file" & sFile & """ "
sCMD = sCMD & sUser & " " & sPW

' Comment out the following after testing
MsgBox "CMD=" & sCMD ' only need this for debugging"

' run the command
Set objShell = CreateObject("WScript.Shell")
objShell.Run sCMD

' close up

LVL 30

Expert Comment

ID: 16949750
>> DOS Batch files have been replaced by Script files

Thats a bit of a blanket statement. Some things are more eloquently done in batch files than VBScript... I believe the solution is dictated by a lot of factors and in some cases a batch file is a better solution.

Anyway thats my 2 cents!
LVL 17

Expert Comment

ID: 16950038
nmcdermaid yes you are write, especially on systems where scripting is blocked by anti-virus.
LVL 17

Expert Comment

ID: 16950045
Write? Did I mean right? Too much coding!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question