Hello. I want to make a program in VB6 so that if you click a button the program asks you in a textbox for user input then it saves the input as a line in a batch file and runs it. Can anyone please help me? It isn't working. Thank you in advance.
Code:Private Declare Function ShellExecute Lib _ "shell32.dll" Alias "ShellExecuteA" _ (ByVal hwnd As Long, ByVal lpOperation _ As String, ByVal lpFile As String, ByVal _ lpParameters As String, ByVal lpDirectory _ As String, ByVal nShowCmd As Long) As Long Const SW_HIDE = 0 Const SW_SHOWNORMAL = 1 Const SW_NORMAL = 1 Const SW_SHOWMINIMIZED = 2 Const SW_SHOWMAXIMIZED = 3 Const SW_MAXIMIZE = 3 Const SW_SHOWNOACTIVATE = 4 Const SW_SHOW = 5 Const SW_MINIMIZE = 6 Const SW_SHOWMINNOACTIVE = 7 Const SW_SHOWNA = 8 Const SW_RESTORE = 9 Const SW_SHOWDEFAULT = 10 Const SW_MAX = 10 Private Sub Command1_Click() usercommand = InputBox("Enter the command") Dim intFF As Long intFF = FreeFile Open "C:\start.bat" For Output As intFF Print intFF, "somecodehere" 'Close intFF Dim intFF2 As Long intFF2 = FreeFile Open "C:\command.bat" For Output As intFF2 Print intFF2, "somecodehere" ' something 'Close intFF2 Dim intFF3 As Long intFF3 = FreeFile 'Open "C:\command.bat" For Append As intFF3 Print intFF3, "usercommand" ShellExecute 0&, vbNullString, "t", vbNullString, _ "C:\=start.bat", SW_SHOWDEFAULT 't = Shell("C:\start.bat") ShellExecute 0&, vbNullString, "z", vbNullString, _ "C:\=command.bat", SW_SHOWDEFAULT 'z = Shell ("C:\command.bat") Dim intFF4 As Long intFF4 = FreeFile Open "C:\=drive.txt" For Input As intFF4 MsgBox (intFF4) Close intFF Close intFF2 Close intFF3 End Sub




Reply With Quote
