c - Calling a batch file from a windows service -


I have a service that needs to call a batch when a new file is copied to the directory I tried to use CreateProcess , ShellExecute , ShellExecuteEx and even system . I tried to call the batch directly, then call cmd.exe and passing the / b batch file as the parameter ... nothing I did not know about the administrator I tried to run the service set with nothing other users.

This is a Windows 2008 server.

Any thoughts? Thank you ..

, as shown in the below (quite simplified) example, there is a valid way of executing A batch file from a service STARTUPINFO si = {0}; PROCESS_INFORMATION pi = {0}; Si.cb = Size (C); If (! CreateProcessA (NULL, "C: \\ test.bat", NULL, NULL, FALSE, 0, NULL, NULL, & SI, and PI)) (four messages [100]; Sprintf (msg, " Create Process () Failed:% d ", GetLastError ()); OutputDebugStringA (msg);}

The logging key is if the batch file is not being executed, CreateProcess () will tell you Why

You mention that the batch file should be executed "When a new file is copied to the directory." Have you verified that the identification code works properly What is the code trying to execute the batch file?

More context will definitely be useful Please post the batch file and relevant sections of the service code.

Comments