Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

select variable

Posted on 2006-06-20
12
Medium Priority
?
204 Views
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).

Willa
0
Comment
Question by:willa666
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 20

Accepted Solution

by:
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 :)

Alain
0
 
LVL 17

Expert Comment

by:inthedark
ID: 16943476
Dim sUser As String
Dim sPW as String

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

Dim PID

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

0
 
LVL 17

Expert Comment

by:inthedark
ID: 16943490
Did not ask for the file name but you get the idea.
0
Industry Leaders: 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!

 
LVL 1

Author Comment

by:willa666
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.
0
 
LVL 17

Expert Comment

by:inthedark
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)
0
 
LVL 30

Expert Comment

by:nmcdermaid
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.
0
 
LVL 20

Expert Comment

by:alainbryden
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.
0
 
LVL 30

Expert Comment

by:nmcdermaid
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.

0
 
LVL 17

Expert Comment

by:inthedark
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.

http://www.computerperformance.co.uk/ezine/ezine26.htm

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.

------------------------------launch.vbs
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
WScript.Quit


0
 
LVL 30

Expert Comment

by:nmcdermaid
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!
0
 
LVL 17

Expert Comment

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

Expert Comment

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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

722 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