winapi - Redirect output of shell commands to file -
i running following command command prompt
dir > c:\log.txt 2>&1
the out directed c:\log.txt
file successfully. then, running same command using createprocessa below , nothing happens
public function execcmd(cmdline$) dim proc process_information dim start startupinfo dim ret long start.cb = len(start) start.dwflags = 1 start.wshowwindow = 1 ret& = createprocessa(vbnullstring, cmdline$, 0&, 0&, 1&, normal_priority_class, 0&, vbnullstring, start, proc) ret = waitforsingleobject(proc.hprocess, infinite) call getexitcodeprocess(proc.hprocess, ret&) call closehandle(proc.hthread) call closehandle(proc.hprocess) execcmd = ret& end function
here cmdline$
passed dir > c:\log.txt 2>&1
i have tried batch file - how redirect output exe after has terminated? , display & redirect output
please suggest wrong here
why don't use shell function? here example of how redirect output:
option explicit private sub form_load() execcmd "dir >c:\log.txt 2>&1" end sub private sub execcmd(cmdline string) shell "cmd /c " & cmdline, vbhide end sub
Comments
Post a Comment