Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

start a batch file from a vb app

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
t60jan
Asked:
t60jan
  • 3
  • 2
1 Solution
 
MirkwoodCommented:
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
 
PoddyCommented:
Use...

shell "C:\command.com /c c:\temp\foo.bat"
0
 
t60janAuthor Commented:
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!

 
MirkwoodCommented:
Hmm, on NT is works OK, in win95 it does not. That proves it everybody should use NT.
0
 
t60janAuthor Commented:
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
 
MirkwoodCommented:
Hmm, on NT is works OK, in win95 it does not. That proves it everybody should use NT.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now