Solved

Running bat files

Posted on 1998-10-29
6
423 Views
Last Modified: 2010-04-30
How do you get a bat file to run?
0
Comment
Question by:jjeva
[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
6 Comments
 
LVL 2

Expert Comment

by:dabellei
ID: 1442361
simpiest way is to use the shell function  here the MSDN topics

Shell Function
     

Runs an executable program and returns a Variant (Double) representing the program's task ID if successful, otherwise it returns zero.

Syntax

Shell(pathname[,windowstyle])

The Shell function syntax has thesenamed arguments:

Part Description
pathname Required; Variant (String). Name of the program to execute and any requiredarguments orcommand-line switches; may include directory or folder and drive.
windowstyle Optional. Variant (Integer) corresponding to the style of the window in which the program is to be run. If windowstyle is omitted, the program is started minimized with focus.


The windowstyle named argument has these values:

Constant Value Description
vbHide 0 Window is hidden and focus is passed to the hidden window.  
vbNormalFocus 1 Window has focus and is restored to its original size and position.
vbMinimizedFocus 2 Window is displayed as an icon with focus.
vbMaximizedFocus 3 Window is maximized with focus.
vbNormalNoFocus 4 Window is restored to its most recent size and position. The currently active window remains active.
vbMinimizedNoFocus 6 Window is displayed as an icon. The currently active window remains active.


Remarks

If the Shell function successfully executes the named file, it returns the task ID of the started program. The task ID is a unique number that identifies the running program. If the Shell function can't start the named program, an error occurs.

Note   By default, the Shell function runs other programs asynchronously. This means that a program started with Shell might not finish executing before the statements following the Shell function are executed.

0
 

Author Comment

by:jjeva
ID: 1442362
I'm pretty new, and didn't understand half of it, just give me the code. I'll probably understand it then
0
 
LVL 1

Accepted Solution

by:
ajmendes earned 10 total points
ID: 1442363
Hi,
try this code:

Dim i As Variant

    i = Shell("C:\windows\command.com <Batch Filename>", vbNormalFocus)

Bye.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 1

Expert Comment

by:ajmendes
ID: 1442364
Hi, it's me again
i'm sorry, but the answer i gave to you is wrong.

Bye.
0
 
LVL 1

Expert Comment

by:ajmendes
ID: 1442365
Hi, i'm back once more

Try this:
Dim i As Variant

    i = Shell("<Batch Complete Filename>", vbNormalFocus)

this will work.
Tell me if it did, and in that case i will repost this as an answer, OK?
Bye.

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1442366
SHELL will work to run a batch file, but it won't wait for it to complete. For that you need the ExecCmd function. Open up the question and I'll post the code.

M

0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…

707 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