Solved

Parameter passing while shelling out to DOS

Posted on 1998-08-18
3
160 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…
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 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…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now