Author Topic: CreateProcess lpCommandLine  (Read 3036 times)

Don57

  • Guest
CreateProcess lpCommandLine
« on: October 10, 2012, 11:06:53 AM »
I'm using qWords code snippet for CreateProcess


                .if !rv(CreateProcess,"c:\Windows\System32\wevtutil.exe","el",0,0,0,CREATE_NEW_CONSOLE or CREATE_NEW_PROCESS_GROUP,0,0, ADDR sui,ADDR pi)
   

 which works fine how ever if I add commands to the lpCommandLine I get syntax errors or nesting errors.

I've tried  ,"el"">>test.txt",
                ,"el" ">>test.txt",
                , "el" ">>" "test.txt",
                and many more

I'm trying to pipe the output to a file so that I can parse it.

qWord

  • Member
  • *****
  • Posts: 1473
  • The base type of a type is the type itself
    • SmplMath macros
Re: CreateProcess lpCommandLine
« Reply #1 on: October 10, 2012, 11:44:52 AM »
That kind of nesting with quoted strings is not possible with MASM. However, you can use escape sequences with the rvc or rvcx macros:

Code: [Select]
rvc(CreateProcess,"\\Windows\\System32\\cmd.exe","/K \q\\Windows\\System32\\ping.exe www.masmforum.com \r xyz.txt\q",0,0,0,CREATE_NEW_CONSOLE,0,0, ADDR sui,ADDR pi)
For the syntax of the macros, please take a look into hlhelp.chm.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: CreateProcess lpCommandLine
« Reply #2 on: October 10, 2012, 11:47:43 AM »
there are several caveats when passing the command line with parameters
read the documentation for CreateProcess - lpCommandLine in particular
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682425%28v=vs.85%29.aspx

what i find works best is to pass a NULL for lpApplicationName and
create the complete command line as a single string - for example...
Code: [Select]
'c:\masm32\ml.exe parm',0of course, you don't need the full path if the file is in the same folder or in the environment PATH