Solved

start a batch file from a vb app

Posted on 1998-10-20
6
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1440770
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
ID: 1440771
Use...

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

Author Comment

by:t60jan
ID: 1440772
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

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

Author Comment

by:t60jan
ID: 1440774
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
ID: 1440775
Hmm, on NT is works OK, in win95 it does not. That proves it everybody should use NT.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

623 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