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
Solved

Parameter passing while shelling out to DOS

Posted on 1998-08-18
3
164 Views
Last Modified: 2010-04-30
I want to shell out to DOS from my program, using a batch file, and run a utility using one of the variables from my program as a parameter.  I've mastered the shelling out, and writing batch files, how do I pass the variable?
0
Comment
Question by:bigc
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
fmismetti earned 50 total points
ID: 1429580
Did you try:

    Dim Ret As Long

    Ret = WinExec("c:\dosprog\d.bat parm1 parm2", 1)

You need to concatenate the batch filename plus your variable(s) converted to strings.

If Ret is greater than 32, the exec is ok.

The parameter 1 is for SW_SHOWNORMAL Constant (look in the API viewer) and controls how the window is showed. You need also to declare:

Declare Function WinExec Lib "kernel32" Alias "WinExec" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long

Hope that help you
0
 

Author Comment

by:bigc
ID: 1429581
The program shells out to DOS and runs the batch file, but is still passing the variable name as the parameter rather than the contents.  

I put the 'Declare Function WinExec Lib ...." in a module, as it wouldn't work in the main section of the program.  

Any more top tips?

Thanks
0
 
LVL 1

Expert Comment

by:fmismetti
ID: 1429582
Well, which is passed to the shell is a single string. In the sample above, I assume that parm1 and parm2 are string variables. If your variable is an integer you should convert and prepare a single string like:

    Dim parm1int as integer
    Dim parm2int as integer
    Dim appname as string
    Dim CommStr as string

    CommmStr=appname & " " & Format(parm1int,"####0") & " " & Format(parm1int,"####0")

    Pass CommStr to WinExec.


0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Looking for VB6 code to read SQL table export it to ascii 8 43
TT Auto Dashboard 13 95
VB 6 error 5 in windows 10 but not in XP 7 63
Zip Folders Using Chilkat Routines 1 58
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

840 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