Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Run Command Line Executable Code?

Posted on 2001-06-14
10
Medium Priority
?
196 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 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

916 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