|
-
Jul 14th, 2000, 06:17 PM
#1
Thread Starter
Junior Member
I want to run a program (Not one I made) that only seems to working Dos. I need to run it from my Program. I have tried using ShellExecute, but it doesn't seem to work.
-
Jul 14th, 2000, 06:54 PM
#2
Fanatic Member
Try using the Shell command instead, like this:
Code:
Shell "C:\MYDIR\MYPROG.EXE"
The Shell command basically works like a DOS prompt. You could call dir like this:
-
Jul 14th, 2000, 07:02 PM
#3
Hyperactive Member
I don't think I completely understand. But I nearly always use the ShellExecute to call a handful of dos apps and the follow code has always worked for me:
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
Private Const SW_NORMAL = 1
Private Sub Command1_Click()
Dim sPrg as string
'Make sure you enter the full path.
sPrg="c:\marcbrkr.exe"
lret = ShellExecute(0&, "open", sPrg, vbNullString, 0&, SW_NORMAL)
End Sub
And if that doesn't work, you can always try the old standby
Code:
Private sub Command1_Click()
Dim x as long
x=Shell("c:\marcbrkr.exe",vbNormalFocus)
end sub
Good luck
-
Jul 14th, 2000, 07:35 PM
#4
Thread Starter
Junior Member
Thanx, that seems to work.
The Shell works fine. Thank you all. Sniff Sniff. You all always seem to have JUST the right answer... I love you guys!
Sorry for the outburst. Thanx/.
-
Jul 14th, 2000, 08:19 PM
#5
You can also use Options from a shell function.
Code:
Shell "Command.com edit /?", VbNormalFocus
Or something like that ;].
[Edited by Matthew Gates on 07-14-2000 at 09:21 PM]
-
Jul 15th, 2000, 09:52 AM
#6
Fanatic Member
Yeah, Shell
Yeah, the Shell command is pretty good. It works most like a DOS command line.
Try this for fun some time (but make sure you don't have a file on the root called Files.txt that you need for anything):
Code:
Shell "dir c:\*.* /s/a/o/l/b > c:\files.txt"
This is just a simple example, but it illustrates that most anything you can do from a DOS command line, you can do from within VB using the Shell command.
Pretty useful for small tasks because it is quick and easy.
-
Jul 15th, 2000, 12:48 PM
#7
Thread Starter
Junior Member
Hmph, Now WHAT!?
Hello Again.
Well what seemed to work eariler no long works now. Even Basic DOS Command like the:
"DIR *.*"
Doesn't work correctly. Any suggestions? It worked fine yesterday, all I did was place the filenames and File Directories into Variables. Thinking this might have been the Problem I undid that...No change.
Also, while I am here...
I have a program that outputs something in DOS (Once again I did not make this one) and I want what it out put to appear in a Text Box. Is there a way to do this?
Adios for now.
-
Jul 15th, 2000, 01:21 PM
#8
Hyperactive Member
To run your DOS program and then read the results you should just send the output to a file and then read it in:
Shell "yourprg.exe > somefile.txt"
Then somefile.txt should store the output.
"People who think they know everything are a great annoyance to those of us who do."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|