How can I run a child process that requires elevation and wait?

Use ShellExecuteEx, rather than ShellExecute. This function will provide a handle for the created process, which you can use to call WaitForSingleObject on that handle to block until that process terminates. Finally, just call CloseHandle on the process handle to close it. Sample code (most of the error checking is omitted for clarity and brevity): … Read more

Exec vs ExecWait vs ExecShell vs nsExec::Exec vs nsExec::ExecToLog vs nsExec::ExecToStack vs ExecDos vs ExeCmd

1) 2) 3) Exec and ExecWait use CreateProcess internally and can only start programs and batch files. ExecShell uses ShellExecute which means that it can also launch any registered filetype (.txt .chm etc) and URLs. It should also be used if the program you are starting needs to elevate with UAC. 4) nsExec redirects stdout … Read more

Lua os.execute return value

You can use io.popen() instead. This returns a file handle you can use to read the output of the command. Something like the following may work: local handle = io.popen(command) local result = handle:read(“*a”) handle:close() Note that this will include the trailing newline (if any) that the command emits.

How to Pass parameters for a Ant script , which is invoked via shell script?

Do you mean assigning value to a property from command line? If so, try -DpropertyName=itsValue For example, <project> <target name=”hi”> <property name=”person” value=”world”/> <echo message=”Hello ${person}”/> </target> </project> and then ant -Dperson=”MerryPrankster” hi yields [echo] Hello MerryPrankster

Exec a shell command in Go

The package “exec” was changed a little bit. The following code worked for me. package main import ( “fmt” “os/exec” ) func main() { app := “echo” arg0 := “-e” arg1 := “Hello world” arg2 := “\n\tfrom” arg3 := “golang” cmd := exec.Command(app, arg0, arg1, arg2, arg3) stdout, err := cmd.Output() if err != nil … Read more