Solved

Run Command Line Executable Code?

Posted on 2001-06-14
10
184 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now