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 "Initializa tion 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.Environm ent.UserDomainN ame + "\\" +
System.Environm ent.UserName);
AddSQLStatement ("User: " +
System.Security .Principal.Wind owsIdentity.Get Current().Name) ;
try {
Process oProc = new Process();
oProc.EnableRai singEvents = false;
oProc.StartInfo .FileName = "XCOPY";
oProc.StartInfo .Arguments = sXCopy;
oProc.StartInfo .RedirectStanda rdOutput = true;
oProc.StartInfo .UseShellExecut e = false;
oProc.Start();
AddSQLStatement ("StdOut: " + oProc.StandardO utput.ReadToEnd ()); ////
oProc.WaitForEx it();
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\Servic eAccount
USER: CSDOMAIN\Servic eAccount
XCOPY: "\\Cochise\JobF olders\_FolderT emplate"
"\\Cochise\JobF olders\6126_Tes t25e" /E /V /C /I /O /Y /K
--
Thanx,
Grigs 2 2197
"Grigs" <Gr***@discussi ons.microsoft.c om> wrote in message
news:D1******** *************** ***********@mic rosoft.com... 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 "Initializa tion 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.Environm ent.UserDomainN ame + "\\" + System.Environm ent.UserName); AddSQLStatement ("User: " + System.Security .Principal.Wind owsIdentity.Get Current().Name) ;
try { Process oProc = new Process(); oProc.EnableRai singEvents = false; oProc.StartInfo .FileName = "XCOPY"; oProc.StartInfo .Arguments = sXCopy; oProc.StartInfo .RedirectStanda rdOutput = true; oProc.StartInfo .UseShellExecut e = false; oProc.Start(); AddSQLStatement ("StdOut: " + oProc.StandardO utput.ReadToEnd ()); //// oProc.WaitForEx it(); 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\Servic eAccount USER: CSDOMAIN\Servic eAccount XCOPY: "\\Cochise\JobF olders\_FolderT emplate" "\\Cochise\JobF olders\6126_Tes t25e" /E /V /C /I /O /Y /K
-- Thanx, Grigs
I may be barking up the wrong tree here, but what is the working directory
when you launch xcopy? I seem to recall that dos commands don't take kindly
to be kicked off on a share and like the current working directory to be
something with a drive letter.
Just a thought.
Brian. www.cryer.co.uk/brian
Brian,
Thanks. I tried your suggestion with no luck. I put in C:\ with no luck.
I even put the exact path to the XCOPY function. I even tested changing the
UNC paths to be a drive letter and that didn't work either.
Anyone have any other suggestions?
--
Thanx,
Grigs
"Brian Cryer" wrote: "Grigs" <Gr***@discussi ons.microsoft.c om> wrote in message news:D1******** *************** ***********@mic rosoft.com... 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 "Initializa tion 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.Environm ent.UserDomainN ame + "\\" + System.Environm ent.UserName); AddSQLStatement ("User: " + System.Security .Principal.Wind owsIdentity.Get Current().Name) ;
try { Process oProc = new Process(); oProc.EnableRai singEvents = false; oProc.StartInfo .FileName = "XCOPY"; oProc.StartInfo .Arguments = sXCopy; oProc.StartInfo .RedirectStanda rdOutput = true; oProc.StartInfo .UseShellExecut e = false; oProc.Start(); AddSQLStatement ("StdOut: " + oProc.StandardO utput.ReadToEnd ()); //// oProc.WaitForEx it(); 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\Servic eAccount USER: CSDOMAIN\Servic eAccount XCOPY: "\\Cochise\JobF olders\_FolderT emplate" "\\Cochise\JobF olders\6126_Tes t25e" /E /V /C /I /O /Y /K
-- Thanx, Grigs
I may be barking up the wrong tree here, but what is the working directory when you launch xcopy? I seem to recall that dos commands don't take kindly to be kicked off on a share and like the current working directory to be something with a drive letter.
Just a thought.
Brian.
www.cryer.co.uk/brian This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: jam |
last post by:
Dear All,
I have a command process running xcopy in console, and now I want to execute
the program Rsync After the files are copied...how could i do??
Process p10=new Process();
p10.StartInfo.FileName = "cmd.exe";
p10.StartInfo.UseShellExecute = false;
// p.StartInfo.CreateNoWindow = true;
p10.StartInfo.RedirectStandardInput = true;
|
by: Samantha |
last post by:
Hello ,
I am developping a program for Win98 plateform, and I am stucking with a
problem, hope you can help me.
I have a program running 2 process :
- One process running the Xcopy.exe
- When the first process is finished, it runs another Exe process (HHC.exe)
The code is below:
|
by: Tony |
last post by:
I am running an application called AcroComm.exe to poll time clocks here at
our company. I have written a small C# app that will poll the clocks based
on information found in a DB. My problem is that AcroComm will sometimes
stop polling in the middle of the process and terminate. The programing
manual for the app says that it sends a code to the operating system when it
is done that tells what has happend like the following:
0 ...
|
by: Christian Billig |
last post by:
Hi,
well i've a problem and i don't know how to solve it.
I wrote a function, which starts a Process for a user by using the API
CreateProcessWithLogon.
Afterwards i want to know if the process already ended and with what
exitcode it has finished.
|
by: Nurit N |
last post by:
This is the third newsgroup that I'm posting my problem.
I'm sorry for the multiple posts but the matter becoming urgent.
I hope this is the right place for it...
I have created a very simple batch file (echo hello world) and was trying to
retrieve the standard output but every time I run the code it returns
ExitCode as 1.
| |
by: Andy |
last post by:
I am calling out to an executable using the System.Diagnostics.Process
methods and specifically attempting to trap for errors (at least trying to
learn how to trap for errors). I arranged the data to specifically error
when calling this executable.
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "intupld.exe";
process.StartInfo.Arguments = hupFile;
process.StartInfo.WorkingDirectory =...
|
by: tenpsa |
last post by:
Hi,
I have a C# application that uses the System.Diagnostics.Process
functionality to execute other processes (to install a couple of .msi
files). Here's my code so far:
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.Arguments = sArgs;
proc.StartInfo.FileName = "msiexec.exe";
proc.StartInfo.WorkingDirectory = sPath;
proc.Start();
|
by: =?Utf-8?B?U3RldmVU?= |
last post by:
I am trying to get the exit code of an application (IE) after the process
closes. On my system I keep getting an exception error. "No process is
associated with the object." The Process class is suppose to keep some
administrative information available on a closed process (i.e., the ExitCode,
HasExited, etc.) but it seems to not do this. Does anyone know how to get
around this problem?
The code is a simple C# form with a button. The...
|
by: vinayakkatkam |
last post by:
public bool ProcessXCopy()
{
string XCopyArguments = "C:\\Documents and Settings\\Vinayak.Katkam\\Desktop\\SYNCHRONIZATION\\BASE-VERSION\\SDDS\\*.* " + "C:\\Documents and Settings\\Vinayak.Katkam\\Desktop\\SYNCHRONIZATIONBACKUP\\BACKUP";
Process XCopyProcess = new Process();
ProcessStartInfo XCopyStartInfo = new ProcessStartInfo();
XCopyStartInfo.FileName = "CMD.exe ";
...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |