?
Solved

Parameter passing while shelling out to DOS

Posted on 1998-08-18
3
Medium Priority
?
169 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
[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
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
fmismetti earned 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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

718 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