Solved

start a batch file from a vb app

Posted on 1998-10-20
6
283 Views
Last Modified: 2010-04-30
Hello friends !!
I am struggling with the problem as described here under:

I use a software application which runs under Dos ON MY File and Database Server using NT 4.0 ( I first have to open a Dos box on my Server).

Every part of the application has it's own batch file to start with.
Example of the contents of one of the batch files is called Grd200.bat and hereunder are it's contents:
 
@ECHO OFFCALL acc9_env.batrem SET PRNTOUT=PRINTERIF EXIST %eigen%\grd200 call %bat%\delete.bat %eigen%\grd200SET PRNTOUT=%eigen%\grd200
SET S=00010000
CALL %bat%\execute GRD20025
:EINDE

This starts a program ( GRD20025 ) which can handle product number maintenance.

What I normally do is the following:

Click on the Dos prompt and a Dos box is opened.
Start the batch file by typing it's name ( name = GRD200.bat ) and hit the Enter key.
Now I can work with the application that starts with this batch file; after exiting the application I come in my dos prompt again
I type EXIT and Windows is 'on the run' again.

I wanted to write a Menu application for this because starting up all these batch files under dos is not a workable situation for a user.   Therefor I have developed an application with Visual basic 6.0 and have build a Menu with the Menu Editor  ( MDI form ).

From that Menu I start a batch file with the following purpose:

Open a Dos box and start start the batch file (GRD200.bat)
Shrink the VB application ( show it down under on the task bar as an icon )
After exexcution of the contents of the batch file: close my Dos box again ; enlarge my VB Menu application again.

Herewith is a print of the code as used; however : something happens but my batch file doesn't seem to be started; I never get the application ( see batch file ) running;, so:

Who can help me writing the right VB code for this problem??       Code:

Private Sub MenGrb200_Click()
Rem:  opstarten vanuit directory op Server Bl3:   U:\Acc9\Bats\Grd200.bat
Rem:  U is directory on my File Server were all batch files ar located
Dim A
A = Shell   ("U:\Acc9\Bats\Grd200.bat ", 3)

End Sub

The Batch file starts but the parameters are not set nor is the exe started. I know this must be possible since a shortcut works and if I do it by hand it works as well. Perhaps there is somebody out there who knows an Api call or an other way to solve this.

Any help will be highly appreciated.

Thanks in advance

Jan Noomen
0
Comment
Question by:t60jan
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
Try this one:

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

I think the system is like this
ShellExecute 0,"Open","xxx.bat", "arg1 arg2", "c:\", 0
0
 
LVL 2

Expert Comment

by:Poddy
Comment Utility
Use...

shell "C:\command.com /c c:\temp\foo.bat"
0
 

Author Comment

by:t60jan
Comment Utility
Neither the comment nor the proposed answer seems to work. The result is still the same. It starts a Dos window and immediately closes it.
Perhaps the problem stems from the fact that my batch file sets a few parameters and then starts an exe. After that the batch is finished and the window closes. It also kills the exe. So everything is gone.
Perhaps you've a solution.

Thanks so far


Jan
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 13

Expert Comment

by:Mirkwood
Comment Utility
Hmm, on NT is works OK, in win95 it does not. That proves it everybody should use NT.
0
 

Author Comment

by:t60jan
Comment Utility
You're so right Mr. Mirkwood
it worked
perhaps you should propose this as an answer, as a result of which you can collect your points

Thank you very much

Jan

However, just in case, do you have a method to make this work under 95/98

0
 
LVL 13

Accepted Solution

by:
Mirkwood earned 100 total points
Comment Utility
Hmm, on NT is works OK, in win95 it does not. That proves it everybody should use NT.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now