Solved

Run Command Line Executable Code?

Posted on 2001-06-14
10
187 Views
Last Modified: 2010-05-02
We have a function that executes a commandline and it works on NT4 but not Win2000.  Is there something different we have to do for 2000 or a way to change it to run on both?

Dim proc As PROCESS_INFORMATION
Dim start As STARTUPINFO
Dim ReturnValue As Integer

' Initialize the STARTUPINFO structure:
start.cb = Len(start)

' Start the shelled application:
ReturnValue = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, _
   NORMAL_PRIORITY_CLASS, 0&, 0&, start, proc)

' Wait for the shelled application to finish:
Do
   ReturnValue = WaitForSingleObject(proc.hProcess, 0)
   DoEvents
Loop Until ReturnValue <> 258

ReturnValue = CloseHandle(proc.hProcess)
0
Comment
Question by:anyanicky
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 3

Expert Comment

by:RodStephens
ID: 6190960
Not an answer but a suggestion: you might try executing the command line from a DOS window in Win2000 to see what it does. Then you can at least verify that the command line can work outside of CreateProcessA.
0
 
LVL 1

Author Comment

by:anyanicky
ID: 6191140
We tried that - runs fine if we do it manually at the dos prompt.  That's what is so strange.
0
 
LVL 3

Accepted Solution

by:
casassus earned 50 total points
ID: 6191211
The return value from CreateProcess is a long and not an integer.
Try to change the data type of ReturnValue and the declaration of the function.

0
Independent Software Vendors: 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!

 
LVL 1

Author Comment

by:anyanicky
ID: 6191224
We tried that - runs fine if we do it manually at the dos prompt.  That's what is so strange.
0
 
LVL 1

Author Comment

by:anyanicky
ID: 6191244
The function's return value is boolean and we are setting it after that code. We don't use ReturnValue after the loop ends - it is just a "catch-all."
0
 
LVL 18

Expert Comment

by:deighton
ID: 6191350
he means that 32 bit createprocess api returns a long not an integer
0
 
LVL 3

Expert Comment

by:RodStephens
ID: 6191413
Yes, although the result may be a Boolean, you need to allocate a long integer to hold the result.

Are you running in the IDE on the Win2000 machine? Can you tell what the error is? Or does it just quietly not start the process?
0
 
LVL 3

Expert Comment

by:casassus
ID: 6191445
What give you the CreateProcessA function as return.
What king of program do you want to launch
0
 
LVL 1

Author Comment

by:anyanicky
ID: 6192077
This function is called from an ASP page.  The process begins and runs for a second and quits.  It runs ok on an NT4 box.
0
 
LVL 3

Expert Comment

by:casassus
ID: 6194613
You can test your procass with GetExitCodeProcess to know his state.
Try it
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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.
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…

680 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