Process Problems - XCOPY ExitCode



Hello,

I am attempting to write a Web Method in my Web Service that starts a
process that runs the XCOPY command with passed in parameters. It is failing
on me through code. However, if I take the exact same string it is passing
and past it into a Command prompt, it works perfectly. That told me it may
be a permissions/impersonation issue. I am now running it as a special
ServiceAccount I have created that is a Domain Admin. It still does not
work. I then looked to see if it was returning an error or ExitCode and it
is.

The ExitCode == 4 which for XCOPY means "Initialization error occurred.
There is not enough memory or disk space, or you entered an invalid drive
name or invalid syntax on the command line."

Here is my code and the output follows - Can anyone help me here? Do I
really need impersonation or is it some other fix?

FYI: The AddSQLStatement method is simply a way I store information in a
string array for extraction later to determine what happens in my code.


string sXCopy = "\"" + sBaseFolder + sSourceFolder + "\"" +
" \"" + sBaseFolder + sDestination + "\"" +
" /E /V /C /I /O /Y /K";

AddSQLStatement("XCOPY: " + sXCopy);
AddSQLStatement("USER: " + System.Environment.UserDomainName + "\\" +
System.Environment.UserName);
AddSQLStatement("User: " +
System.Security.Principal.WindowsIdentity.GetCurrent().Name);

try {
Process oProc = new Process();
oProc.EnableRaisingEvents = false;
oProc.StartInfo.FileName = "XCOPY";
oProc.StartInfo.Arguments = sXCopy;
oProc.StartInfo.RedirectStandardOutput = true;
oProc.StartInfo.UseShellExecute = false;
oProc.Start();
AddSQLStatement("StdOut: " + oProc.StandardOutput.ReadToEnd()); ////
oProc.WaitForExit();
AddSQLStatement("Exit Code: " + oProc.ExitCode.ToString()); ////
} catch(Exception e) {
AddSQLStatement("XCOPY Error: " + e.ToString());
exLastError = e;
} // try-catch

<<<<<< This is the output >>>>>>>>

Exit Code: 4
StdOut: 0 File(s) copied
User: CSDomain\ServiceAccount
USER: CSDOMAIN\ServiceAccount
XCOPY: "\\Cochise\JobFolders\_FolderTemplate"
"\\Cochise\JobFolders\6126_Test25e" /E /V /C /I /O /Y /K

--
Thanx,
Grigs
.



Relevant Pages

  • Re: Process Problems - XCOPY ExitCode
    ... > I am attempting to write a Web Method in my Web Service that starts a ... > process that runs the XCOPY command with passed in parameters. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Execute stored procedure via web method.
    ... XML, but it looks straight forward, where would XML code go? ... I can't pass and Oracle Command or the parameter objects object ... >> string that I can pass to the web method and execute it as such? ... You then need to map back and forth from your types at the web service ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: writing/publishing/consuming
    ... \par "Whether it will generated cs file or dll" is not important for the two approaches as both of them can generate dll and cs file. ... Is there an advantage to using the command line? ... \par> and after writing a web service to convert temperatures between ... \par> Generating a proxy class of the service. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: writing/publishing/consuming
    ... "Whether it will generated cs file or dll" is not important for the two approaches as both of them can generate dll and cs file. ... ** In Visual Studio, the visual approach is integrated with IDE and as long as you use VS to generate the webservice proxy, IDE will help you do a lot of things(such as call the command with parameters get from your GUI input). ... Also, when you want to update a proxy, you can simply right click it to update. ... and after writing a web service to convert temperatures between ...
    (microsoft.public.dotnet.framework.webservices)
  • Errors when accessing data from a webservice
    ... I am having a problem developing a web service that is accessing data using ... OLE or ODBC, however this problem is only occurring on 1 development PC ... startRecord, Int32 maxRecords, String srcTable, IDbCommand command, ... dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand ...
    (microsoft.public.dotnet.framework.aspnet.webservices)