Solved

select variable

Posted on 2006-06-20
12
199 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
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 20

Accepted Solution

by:
alainbryden earned 500 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now