Run Command Line Executable Code?

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)
LVL 1
anyanickyAsked:
Who is Participating?
 
casassusConnect With a Mentor Commented:
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
 
RodStephensCommented:
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
 
anyanickyAuthor Commented:
We tried that - runs fine if we do it manually at the dos prompt.  That's what is so strange.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
anyanickyAuthor Commented:
We tried that - runs fine if we do it manually at the dos prompt.  That's what is so strange.
0
 
anyanickyAuthor Commented:
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
 
deightonCommented:
he means that 32 bit createprocess api returns a long not an integer
0
 
RodStephensCommented:
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
 
casassusCommented:
What give you the CreateProcessA function as return.
What king of program do you want to launch
0
 
anyanickyAuthor Commented:
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
 
casassusCommented:
You can test your procass with GetExitCodeProcess to know his state.
Try it
0
All Courses

From novice to tech pro — start learning today.