Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Running bat files

Posted on 1998-10-29
6
Medium Priority
?
441 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 20 total points
ID: 1442363
Hi,
try this code:

Dim i As Variant

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

Bye.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
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

610 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