Multi-line Winexec command

Solution Available
Andrew Y.
Bristol, PA

Sep 14, 2016
5 Posts

1  |  0  

Re: Multi-line Winexec command

Hello,

I am trying to run a dos command that I can get to run in cmd.exe:

cd C:\PCI3362LVInterface\CDM\support && C:\PCI3362LVInterface\CDM\support\DataCapture.exe -Hlocalhost -jProjectManager -cProcessing -r25 -t1000 -n25 "NCC2916 01-01-01" "C:\PCI3362LVInterface\CDM\support\outfile.txt"

However I seem to not be able to get to run using winexec.

If I just try:
hHandle = winexec("C:\\PCI3362LVInterface\\CDM\\support",aformShow)
or
hHandle = winexec("cd C:\\PCI3362LVInterface\\CDM\\support",aformShow)
I get an error code of 2, file not found.

Is there a simpler way to handle this?  I prefer not to use batch file as some of the items in the command prompt will change and would rather keep it inside ATEasy.

Thanks.
Andy

DrATEasy (Ron Y.)
Mission Viejo, CA

Sep 14, 2016
358 Posts

0  |  0  

Re: Multi-line Winexec command

You need to execute the command line first followed by your command. For example:
WinExec("cmd.exe /K dir")

Use the /K and /C and also make sure to have quote or quote for each command between &&

See https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true

Andrew Y.
Bristol, PA

Sep 14, 2016
5 Posts

0  |  0  

Re: Multi-line Winexec command

Outstanding, thanks Ron.

Orr K.
Irvine, CA

Mar 24, 2017
21 Posts

0  |  0  

Re: Multi-line Winexec command

DrATEasy (Ron Y.) wrote:
You need to execute the command line first followed by your command. For example:
WinExec("cmd.exe /K dir")

Use the /K and /C and also make sure to have quote or quote for each command between &&

See https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true


If you follow these instructions you should be able to get this to work.

DrATEasy (Ron Y.)
Mission Viejo, CA

Jan 29, 2018
358 Posts

0  |  0  

Re: Multi-line Winexec command

Place all of these line with a .bat file and execute it using WinExec("c:\\MyBatFlder\\Example.bat").

Every time you are calling WinExec a new process is created and it does not related to another WinExec call.  

In addition, CD command is not  an executable it runs only within CMD.



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]