Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run Command Line Executable Code?

Posted on 2001-06-14
10
Medium Priority
?
194 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
[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
  • 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 200 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
Industry Leaders: 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses

705 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