Solved

start a batch file from a vb app

Posted on 1998-10-20
6
286 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
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 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