Using Input Box and a Command Button to launch a DOS app


all, thanks for any input. Using VB6 I have a requirement to create a simple 3 command button interface to perform some DOS command line syntax

the buttons will be taking input from three Input boxes

add user
BESUserAdminClient -add -u <1stInputBox> -p <2ndInputBox>

delete user
BESUserAdminClient -del -u <1stInputBox>

add IT policy
BESUserAdminClient -add -itpolicy <3rdInputBox>

total novice at VB6 so any help would be useful.
carrollbluesfanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gilbarCommented:
there is a Shell command in vb that will let you enter batch commands, but it doesn't wait for the command to finish before going on to the next vb command. So i like to use the WSH object Shell, like this:

Cmd1 = "dir > C:\test.txt"
Set objWsh = CreateObject("WScript.Shell")
Call objWsh.Run("cmd /c " & Cmd1, 0, True)
Set objWsh = Nothing

you need the cmd /c part so that you can run things built into dos (that is, that aren't .exe's)
the ,True part tells it to wait for the doc command to finish before continuing
The .Run command doesn't show up as a command prompt window, but also doesn't allow results to be returned, thus the pipe for my dir command.  Another way to get results is to use the .Exec command instead, but it shows up as a blak command prompt which i find distracting. Here should be a link to the help page for these:
http://www.microsoft.com/technet/scriptcenter/guide/default.mspx
Michael_DCommented:
By "input boxes" you mean TextBox Controls or Popup window that get user's input?
Michael_DCommented:
If its Textboxes You can use something like this:

Private Sub Command1_Click()
Dim Cmd As String
Cmd = "BESUserAdminClient -add -u " & Text1.Text & " -p " & Text2.Text
Shell Cmd
End Sub

Private Sub Command2_Click()
Dim Cmd As String
Cmd = "BESUserAdminClient -del -u " & Text1.Text
Shell Cmd
End Sub

Private Sub Command3_Click()
Dim Cmd As String
Cmd = "BESUserAdminClient -add -itpolicy" & Text3.Text
Shell Cmd
End Sub


Its good Idea to check user input prior to execute the command:
Like this :

Private Sub Command2_Click()

If Text1.Text="" Then
   MsgBox "Please enter valid Username"
   Exit Sub
End If

Dim Cmd As String
Cmd = "BESUserAdminClient -del -u " & Text1.Text
Shell Cmd
End Sub

Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

carrollbluesfanAuthor Commented:

Thanks Mike, I'll check this over the weekend on the machine I'm using...
carrollbluesfanAuthor Commented:

That would be a PopUp window that gets a user input
Michael_DCommented:
then you have to change it to something like this:

Private Sub Command1_Click()
Dim Cmd As String
Dim UserName As String
Dim Pwd As String
UserName = InputBox("Enter User Name")
Pwd = InputBox("Enter Password For User " & UserName)

Cmd = "BESUserAdminClient -add -u " & UserName & " -p " & Pwd
Shell Cmd
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.