carrollbluesfan
asked on
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.
By "input boxes" you mean TextBox Controls or Popup window that get user's input?
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
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
ASKER
Thanks Mike, I'll check this over the weekend on the machine I'm using...
ASKER
That would be a PopUp window that gets a user input
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cmd1 = "dir > C:\test.txt"
Set objWsh = CreateObject("WScript.Shel
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