473,385 Members | 1,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Issue using Process.Start() to execute command line statement

I am having issues copying files from network drive to local machine using
xcopy. The following code works alright for a console application, but as
soon as i call this code in Form Load event of windows application it does
not work. I am confused here, it copies files in a console application, but
not windows app

ProcessStartInfo info = new ProcessStartInfo("xcopy", "");
info.FileName = "xcopy";
info.Arguments = string.Format("\"{0}\" \"{1}\" /r/e/c/i/y/d",
@"\\melsrv01\Public\Templates\Austock Office\.",
@"C:\temp\Test Images");
info.UseShellExecute = false;
info.RedirectStandardOutput = true;

Process process = Process.Start(info);
string result = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Console.WriteLine(result);
//MessageBox.Show(result);
Please help. Thanks

Oct 25 '07 #1
5 5834
"Job Lot" <Jo****@discussions.microsoft.comwrote in message
news:BF**********************************@microsof t.com...
>I am having issues copying files from network drive to local machine using
xcopy. The following code works alright for a console application, but as
soon as i call this code in Form Load event of windows application it does
not work. I am confused here, it copies files in a console application,
but
not windows app
What do you mean by "does not work"?
Oct 25 '07 #2
It copies the file from network drive to local machine in the console
application, but does not copy anything when the same code is used in Form
Load event of the windows application.
"John Vottero" wrote:
"Job Lot" <Jo****@discussions.microsoft.comwrote in message
news:BF**********************************@microsof t.com...
I am having issues copying files from network drive to local machine using
xcopy. The following code works alright for a console application, but as
soon as i call this code in Form Load event of windows application it does
not work. I am confused here, it copies files in a console application,
but
not windows app

What do you mean by "does not work"?

Oct 26 '07 #3
It's a quirk of xcopy.exe; when you redirect output you have to
redirect input too. If you don't, it immediately (and silently) quits
right after startup.

Oct 26 '07 #4
As a complete aside - can I recommend robocopy as a replacement to
xcopy? You can download from Microsoft, or it is included in Vista; it
does more, does it better, and does it quicker.

Marc
Oct 26 '07 #5
Thanks hp******@gmail.com that did the trick. I didn't find any mention of
that in MSDN !!!

"hp******@gmail.com" wrote:
It's a quirk of xcopy.exe; when you redirect output you have to
redirect input too. If you don't, it immediately (and silently) quits
right after startup.

Oct 28 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Matt Calhoon | last post by:
Hi there, I have specified a aspnet user account to run all .net sites. This account needs access to start a .BAT File (in my global.asax on session start the app needs to execute this bat...
4
by: banz | last post by:
Hello I have a problem to resolve: I wrote a Perlscript which caches data from a server (local on my machine) I would like to have a other connection to a remote server but I don't know how to...
2
by: Dave | last post by:
I need to create an executible that will run on a nightly basis. The executible is a simple command line statement like: OSQL -Usa -PmyPasword -n -Q "BACKUP DATABASE msdb TO DISK =...
2
by: Joey Mack | last post by:
Greetings. I am trying to use the System.Diagnostics.Process class to perform some actions through the Windows command line. The applicable code appears below. The code builds the follow command...
0
by: wayne hamilton | last post by:
I'm having a problem Interacting with Command Line programs. I can read and write anything I want as long as I don't have to interact with a process once it's started. Originally I had been calling...
3
by: David Eadie | last post by:
G'Day all, I cant for the God in me work out how to execute the following command line in vb.net: (watch for the word wrapping also) Sub(ByVal username As String) Shell("ECHO Y| cacls...
0
by: Patrick A. | last post by:
Dll written in VB.NET 2003 to start a command remotely. You can : - launch the command and wait until it's finished. (Ex. 1) - launch the command providing a timeout in seconds, it will wait...
1
by: Brad | last post by:
I have an issue trying to execute commands in a web service. The command starts under the specified user. However, it never completes its execution. I can execute simple commands like "echo HELLO"...
1
by: henrymania | last post by:
Am writing a code for database backup....by backupservlet is as given below i get the following exception
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.