I have used CreateProcessAsUserW function to execute the command and also used CreateFileW function for creating the text file to log the command execution by passing this f