I can't get this to work right.

Notepad opens, but not the text file.


Program db    "c:\windows\notepad.exe",0
Params  db    "C:\Backup\test.txt",0
Startup db    "c:\windows",0


StartupInfo STARTUPINFO<?>



      invoke GetStartupInfo, addr StartupInfo

invoke CreateProcess,addr Program,addr Params,0, 0, FALSE, \
NORMAL_PRIORITY_CLASS, 0, addr Startup, addr StartupInfo, addr ProcessInfo

Posted on 2010-09-03 18:24:52 by skywalker
Note sure if this helps... Hopefully it does...

About:  %WINDIR%\System32\notepad.exe

  This application also ignores everything in the cmdargs string
  that precedes a "/C".

  To use the CreateProcess() to launch Notepad.exe and have Notepad
  open a file to edit, the cmdargs string must have somewhere a "/C"
  followed by a filename to which Notepad is to edit.

  cmdname = "Notepad.exe"
  cmdargs = "anything to be discarded... /C filename.txt"

Posted on 2010-09-03 19:32:36 by JimmyClif
This works but the debugger opens up with Error_Sucess ?

Params  db    '/C \Backup\test.txt',0
Posted on 2010-09-03 19:52:27 by skywalker
My bad, forgot ExitProcess.

Posted on 2010-09-03 19:56:57 by skywalker

CreateProcess() is peculiar function in that aspect. lpCommandLine argument's first token (space- or doublequote-delimited) is expected to be application image file name only if lpApplicationName is NULL.

Otherwise it can be anything (because command line is passed verbatim) and should be skipped by application before parsing its options/arguments in string returned by GetCommandLine().
Posted on 2010-09-09 11:15:44 by baldr
MSDN's entry on CreateProcess() tends to agree with baldr.
Posted on 2010-09-09 12:21:48 by SpooK
Posted on 2010-09-09 15:29:56 by skywalker