I have faced a case when the same batch file works differently from command line and when it is fired from a WCF service hosted on IIS. The difference is in XCOPY command. when I am running the batch file normally than XCOPY moves all data I need
XCOPY "C:\from" "C:\to" /K /R /E /I /S /C /H /G /X /Y
but when it runs from the WCF service nothing is copied. for running the batch from my service I am using the following code Executing Batch File in C# whith some little modifications. My Application pull is running under LocalSystem account. I also tryed to use my own account for the application poll - does not work. what is wrong?
Short update: What I have learned recently is that my WCF service is running under the App Pool User, but the process isn't. In purpose of experiment I have made an update in the process-start code
var pwdArray = "mypassword".ToArray();
var pwd = new System.Security.SecureString();
Array.ForEach(pwdArray, pwd.AppendChar);
processInfo.UserName = "myuser";
processInfo.Password = pwd;
processInfo.Domain = "LocalMachine";
but it does not help. Seems there is a mystic in running XCOPY under described conditions.
One more update: The same problem with XCopy is also found in a process that starts under a regular windows service.