I am writing a (Win32 Console) program that terminates another process; It takes parameters, as in the following example:
runas.exe user notepad foo.txt
That is: it runasanalyzes userand then starts the notebook, passing the remaining parameters.
My problem is that it argvbreaks down into individual parameters, but CreateProcessAsUserone parameter is required lpszCommandLine.
Building this command line is probably not as simple as simply combining argvbackwards with spaces. Any pointers?
This is just an example. My first argument is not really a username and may contain spaces. This makes GetCommandLineit difficult to manually analyze the result .
Similarly, naive concatenation argvwill not work, because it must deal with the case where the original arguments were quoted and may contain spaces in them.
source
share