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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with displaying message box? 1

Status
Not open for further replies.

DazzaC

Programmer
Jun 10, 2002
209
GB
Hello guys,
I require a little assistance with a problem I am experiencing?
I have a VBScript that calls an application using the Shell command

Shell "c:\di_diver\version1\integ.bat", vbNormalFocus

This opens a cmd window and the application executes in this window.
What I cannot figure out is how to only display the Msgbox "Extract Complete" when this has finished?
As it stands the Message box appears as soon as the extract starts?
Any ideas how to only show this when the extract completes?
At the moment sometimes it does not complete properly (no drive mapping) but appears to the operators as though it has worked?
Thanks
 
Hello DazzaC,

Specify the bWaitOnReturn like this.
Code:
Shell "c:\di_diver\version1\integ.bat", vbNormalFocus, true
regards - tsuji
 
I tried this and received an error message:

This is the code:

Private Sub Command3_Click()
'Execute script. Script uses integ.exe and liverpool1.int to capture date range
Shell "c:\di_diver\version1\integ.bat", vbNormalFocus, True
MsgBox "Daily Extract Completed. Please proceed to next step", vbInformation, "Extract Complete"
End Sub

Error message:

Wrong number of arguements or invlaid property assignment?
 
DazzaC,

What is Shell? What does the line look like where you instantiate it?

- tsuji
 
Correction:

Of course, you need .run. (I've copy & paste your line!)
Code:
set Shell=createobject("wscript.shell")
Shell.run "c:\di_diver\version1\integ.bat", vbNormalFocus, true
- tsuji
 
Hi tsuji,

Thanks for your help. Still experiencing problems tho?

When I attempt to compile the program I get an error on the line:

Set Shell = CreateObject("wscript.shell")

Compile Error: Argument not optional

Thanks
 
DazzaC,

Are you doing in vb? If yes, pose to vb forum.

- tsuji
 
I had it posted there and others advised me to post it here!!

I will post it there as well thanks
 
Sorry, yes I am doing it ib VB as well Vb 6?
 
DazzaC,

To do synchronous execution using shell, you need more coding. You monitor the process from the return value of shell(), the handle of it, by OpenProcess(). Then use GetExitCodeProcess() to check whether the process is still alive. If no longer, CloseHandle() of it. I think, vb forum will give you better advice.

- tsuji
 
As you're in VB, Shell is a reserved word (in fact a function).
You may try something like this:
Set Sh = CreateObject("WScript.Shell")
Sh.Run "c:\di_diver\version1\integ.bat", vbNormalFocus, True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV, Many thanks this resolved my problem!!!

A star for you!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top