Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launch DOS app from VB app

Status
Not open for further replies.

Dinobrago

Technical User
Dec 8, 2001
184
US
I am writing a VB app that constructs a command string which then needs to be launched in DOS and wait for the returned status. The equivalent in VB Script is to create a WSH and Run the command ie:

Dim cmdString
cmdString = "App.exe -flag1 inputArg"
Set objShell = CreateObject("WScript.Shell")
rval = objShell.Run(cmdString, 0, True)

I need to recreate this in a VB application. Any ideas?

Dino
 
well, you could shell it like
Code:
shell cmdString
and in your command string you could > to a file
so your command string might be something like "dir /a >lala.tmp" and then you read lala.tmp for return status.
i know this is a crap way to do it, but i cant help more than than. might give you some ideas?
 
There are multiple examples in this forum on how to do this sort of thing. Do a search for ShellAndWait or similar. You should get a fair number of hits.
 
I agree with strongm.
But for anyone interested try checking out the ShellExecute API (Shell controls) for anything you need to launch from VB.
You can even launch URL strings if you open iexplore and supply the URL as the default directory. Give a man a program and tomorrow he will be hungry.
Teach a man to program and he will never hunger again.
--Sunr¿se

 
I will check out your suggestions.

But I think there may be more to it:
I need to execute the app synchronously and I need to get that status back.

Shell cmdstring only executes async and you can't get the status back except may be as suggested by BlueAvatar. I'll check that out.

I just found a reference by looking up shell that basically says it can't be done from VB.

I will check out your suggestions and let you know what I find.

Dino

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top