473,399 Members | 3,888 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,399 software developers and data experts.

Batchfile with xcopy

Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInfo
Dim sa As New ArrayList
Dim s As String
Try
With info
..FileName = "c:\test.bat"
..RedirectStandardError = True
..UseShellExecute = False
..RedirectStandardOutput = True
End With
p = Process.Start(info)
While Not (p.HasExited)
End While
sa.Add("StandardError: " & p.StandardError.ReadToEnd())
sa.Add("StandardOutput: " & p.StandardOutput.ReadToEnd())
sa.Add("ExitCode: " & p.ExitCode)
sa.Add("ExitTime: " & p.ExitTime)
sa.Add("HasExited: " & p.HasExited)
Catch ex As Exception
sa.Add("Exception: " & ex.Message)
End Try

It works great if the C:\test.bat file contains something like:
copy D:\*.* X:\

But it dows not work if the C:\test.bat file contains somthing including
xcopy like:
xcopy D:\*.* X:\

The data to transfer is not more than ~1 MB in both cases, though xcopy
copies the
sub directories too.

Could anyone please help me.

Thanx a lot.

volker
Nov 20 '05 #1
5 2873
1.
instead of
While Not (p.HasExited)
End While

use
p.WaitForExit ...
2.
what is the output of the process?

--

"I didn't think it was physically possible, but this both sucks and
blows." - Bart Simpson
"Volker Jobst" <bu****@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInfo
Dim sa As New ArrayList
Dim s As String
Try
With info
.FileName = "c:\test.bat"
.RedirectStandardError = True
.UseShellExecute = False
.RedirectStandardOutput = True
End With
p = Process.Start(info)
While Not (p.HasExited)
End While
sa.Add("StandardError: " & p.StandardError.ReadToEnd())
sa.Add("StandardOutput: " & p.StandardOutput.ReadToEnd())
sa.Add("ExitCode: " & p.ExitCode)
sa.Add("ExitTime: " & p.ExitTime)
sa.Add("HasExited: " & p.HasExited)
Catch ex As Exception
sa.Add("Exception: " & ex.Message)
End Try

It works great if the C:\test.bat file contains something like:
copy D:\*.* X:\

But it dows not work if the C:\test.bat file contains somthing including
xcopy like:
xcopy D:\*.* X:\

The data to transfer is not more than ~1 MB in both cases, though xcopy
copies the
sub directories too.

Could anyone please help me.

Thanx a lot.

volker

Nov 20 '05 #2
My problem is, that the code behind the p = Process.Start(info) never
starts.

So there is no output and I don't know where to start, but the xcopy must be
involved
because without it the batchfile and the hole program work.

If I change my code from

While Not (p.HasExited)
End While

to

WriteLine("Here1")
p.WaitForExit()
WriteLine("Here2")

there is no "Here2" on the screen, though I have been waiting long enough.
The app just hangs.

If a don't use the /e in the xcopy command, it works, excluding
subdirectories.
When I doubleclick the C:\test.bat, it works fine, even with /e.

So the orror must be in there, but I don't know where to ask.

volker
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:er**************@TK2MSFTNGP10.phx.gbl...
1.
instead of
While Not (p.HasExited)
End While

use
p.WaitForExit ...
2.
what is the output of the process?

--

"I didn't think it was physically possible, but this both sucks and
blows." - Bart Simpson
"Volker Jobst" <bu****@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInfo
Dim sa As New ArrayList
Dim s As String
Try
With info
.FileName = "c:\test.bat"
.RedirectStandardError = True
.UseShellExecute = False
.RedirectStandardOutput = True
End With
p = Process.Start(info)
While Not (p.HasExited)
End While
sa.Add("StandardError: " & p.StandardError.ReadToEnd())
sa.Add("StandardOutput: " & p.StandardOutput.ReadToEnd())
sa.Add("ExitCode: " & p.ExitCode)
sa.Add("ExitTime: " & p.ExitTime)
sa.Add("HasExited: " & p.HasExited)
Catch ex As Exception
sa.Add("Exception: " & ex.Message)
End Try

It works great if the C:\test.bat file contains something like:
copy D:\*.* X:\

But it dows not work if the C:\test.bat file contains somthing including
xcopy like:
xcopy D:\*.* X:\

The data to transfer is not more than ~1 MB in both cases, though xcopy
copies the
sub directories too.

Could anyone please help me.

Thanx a lot.

volker



Nov 20 '05 #3
strange...
isn't the xcopy waiting for some user input?
"Volker Jobst" <bu****@gmx.de> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
My problem is, that the code behind the p = Process.Start(info) never
starts.

So there is no output and I don't know where to start, but the xcopy must be involved
because without it the batchfile and the hole program work.

If I change my code from

While Not (p.HasExited)
End While

to

WriteLine("Here1")
p.WaitForExit()
WriteLine("Here2")

there is no "Here2" on the screen, though I have been waiting long enough.
The app just hangs.

If a don't use the /e in the xcopy command, it works, excluding
subdirectories.
When I doubleclick the C:\test.bat, it works fine, even with /e.

So the orror must be in there, but I don't know where to ask.

volker
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:er**************@TK2MSFTNGP10.phx.gbl...
1.
instead of
While Not (p.HasExited)
End While

use
p.WaitForExit ...
2.
what is the output of the process?

--

"I didn't think it was physically possible, but this both sucks and
blows." - Bart Simpson
"Volker Jobst" <bu****@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInfo
Dim sa As New ArrayList
Dim s As String
Try
With info
.FileName = "c:\test.bat"
.RedirectStandardError = True
.UseShellExecute = False
.RedirectStandardOutput = True
End With
p = Process.Start(info)
While Not (p.HasExited)
End While
sa.Add("StandardError: " & p.StandardError.ReadToEnd())
sa.Add("StandardOutput: " & p.StandardOutput.ReadToEnd())
sa.Add("ExitCode: " & p.ExitCode)
sa.Add("ExitTime: " & p.ExitTime)
sa.Add("HasExited: " & p.HasExited)
Catch ex As Exception
sa.Add("Exception: " & ex.Message)
End Try

It works great if the C:\test.bat file contains something like:
copy D:\*.* X:\

But it dows not work if the C:\test.bat file contains somthing including xcopy like:
xcopy D:\*.* X:\

The data to transfer is not more than ~1 MB in both cases, though xcopy copies the
sub directories too.

Could anyone please help me.

Thanx a lot.

volker



Nov 20 '05 #4
No, there can't be any waiting for input.

Thanx a lot Dominique, but I can't see a solution.

"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:eg**************@TK2MSFTNGP10.phx.gbl...
strange...
isn't the xcopy waiting for some user input?
"Volker Jobst" <bu****@gmx.de> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
My problem is, that the code behind the p = Process.Start(info) never
starts.

So there is no output and I don't know where to start, but the xcopy must
be
involved
because without it the batchfile and the hole program work.

If I change my code from

While Not (p.HasExited)
End While

to

WriteLine("Here1")
p.WaitForExit()
WriteLine("Here2")

there is no "Here2" on the screen, though I have been waiting long enough. The app just hangs.

If a don't use the /e in the xcopy command, it works, excluding
subdirectories.
When I doubleclick the C:\test.bat, it works fine, even with /e.

So the orror must be in there, but I don't know where to ask.

volker
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:er**************@TK2MSFTNGP10.phx.gbl...
1.
instead of
While Not (p.HasExited)
End While

use
p.WaitForExit ...
2.
what is the output of the process?

--

"I didn't think it was physically possible, but this both sucks and
blows." - Bart Simpson
"Volker Jobst" <bu****@gmx.de> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> Hi.
>
> I have this code:
>
> Dim p As New Process
> Dim info As New ProcessStartInfo
> Dim sa As New ArrayList
> Dim s As String
> Try
> With info
> .FileName = "c:\test.bat"
> .RedirectStandardError = True
> .UseShellExecute = False
> .RedirectStandardOutput = True
> End With
> p = Process.Start(info)
> While Not (p.HasExited)
> End While
> sa.Add("StandardError: " & p.StandardError.ReadToEnd())
> sa.Add("StandardOutput: " & p.StandardOutput.ReadToEnd())
> sa.Add("ExitCode: " & p.ExitCode)
> sa.Add("ExitTime: " & p.ExitTime)
> sa.Add("HasExited: " & p.HasExited)
> Catch ex As Exception
> sa.Add("Exception: " & ex.Message)
> End Try
>
> It works great if the C:\test.bat file contains something like:
> copy D:\*.* X:\
>
> But it dows not work if the C:\test.bat file contains somthing

including > xcopy like:
> xcopy D:\*.* X:\
>
> The data to transfer is not more than ~1 MB in both cases, though xcopy > copies the
> sub directories too.
>
> Could anyone please help me.
>
> Thanx a lot.
>
> volker
>
>



Nov 20 '05 #5
Now I'm just pipelining the output into a text file like:
xcopy D:\*.* X:\ >C:\result.txt
and it works fine now.

"Volker Jobst" <bu****@gmx.de> wrote in message
news:OS**************@TK2MSFTNGP10.phx.gbl...
No, there can't be any waiting for input.

Thanx a lot Dominique, but I can't see a solution.

"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in
message news:eg**************@TK2MSFTNGP10.phx.gbl...
strange...
isn't the xcopy waiting for some user input?
"Volker Jobst" <bu****@gmx.de> wrote in message
news:Or**************@TK2MSFTNGP09.phx.gbl...
My problem is, that the code behind the p = Process.Start(info) never
starts.

So there is no output and I don't know where to start, but the xcopy must
be
involved
because without it the batchfile and the hole program work.

If I change my code from

While Not (p.HasExited)
End While

to

WriteLine("Here1")
p.WaitForExit()
WriteLine("Here2")

there is no "Here2" on the screen, though I have been waiting long

enough. The app just hangs.

If a don't use the /e in the xcopy command, it works, excluding
subdirectories.
When I doubleclick the C:\test.bat, it works fine, even with /e.

So the orror must be in there, but I don't know where to ask.

volker
"Dominique Vandensteen" <domi.vds_insert@tralala_tenforce.com> wrote in message news:er**************@TK2MSFTNGP10.phx.gbl...
> 1.
> instead of
> While Not (p.HasExited)
> End While
>
> use
> p.WaitForExit ...
>
>
> 2.
> what is the output of the process?
>
>
>
> --
>
> "I didn't think it was physically possible, but this both sucks and
> blows." - Bart Simpson
>
>
> "Volker Jobst" <bu****@gmx.de> wrote in message
> news:%2****************@TK2MSFTNGP12.phx.gbl...
> > Hi.
> >
> > I have this code:
> >
> > Dim p As New Process
> > Dim info As New ProcessStartInfo
> > Dim sa As New ArrayList
> > Dim s As String
> > Try
> > With info
> > .FileName = "c:\test.bat"
> > .RedirectStandardError = True
> > .UseShellExecute = False
> > .RedirectStandardOutput = True
> > End With
> > p = Process.Start(info)
> > While Not (p.HasExited)
> > End While
> > sa.Add("StandardError: " & p.StandardError.ReadToEnd())
> > sa.Add("StandardOutput: " & p.StandardOutput.ReadToEnd())
> > sa.Add("ExitCode: " & p.ExitCode)
> > sa.Add("ExitTime: " & p.ExitTime)
> > sa.Add("HasExited: " & p.HasExited)
> > Catch ex As Exception
> > sa.Add("Exception: " & ex.Message)
> > End Try
> >
> > It works great if the C:\test.bat file contains something like:
> > copy D:\*.* X:\
> >
> > But it dows not work if the C:\test.bat file contains somthing

including
> > xcopy like:
> > xcopy D:\*.* X:\
> >
> > The data to transfer is not more than ~1 MB in both cases, though

xcopy
> > copies the
> > sub directories too.
> >
> > Could anyone please help me.
> >
> > Thanx a lot.
> >
> > volker
> >
> >
>
>



Nov 20 '05 #6

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

Similar topics

6
by: xo55ox | last post by:
After setting up the linked server connection at the standby server, I tried to xcopy a file through the sql server 2000 schedule task to the standby server's shared directory. But it keeps giving...
3
by: Ryno Rijnsburger | last post by:
I am busy packaging our product as a standard Setup project in VS.NET that uses a bunch of merge modules (basically, a merge module for every key infrastructure component in our system). Part...
6
by: Zeya | last post by:
I am developing a ASP.Net(Web) based deployment tool, which requires XCOPY functionality. Here is the code for the method: public static int ExecuteProcess ( string ProcessName, string...
2
by: Bruce Schechter | last post by:
Whereas Microsoft highlights the concept of "xcopy deployment" for .NET applications, I gather that it is not necessarily possible to move an ASP.NET application from one computer to another via...
2
by: Grigs | last post by:
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...
1
by: lizii | last post by:
At the moment my company have asked me to look into installations. We use pure .NET applications and although i have looked into installer programs (installshield...wise..etc) none of them are...
1
by: vinayakkatkam | last post by:
public bool ProcessXCopy() { string XCopyArguments = "C:\\Documents and Settings\\Vinayak.Katkam\\Desktop\\SYNCHRONIZATION\\BASE-VERSION\\SDDS\\*.* " + "C:\\Documents and...
1
by: Dave | last post by:
I'm trying to do the following xcopy from my Windows installer and it doesn't work. I even tried running the installer as user with credentials instead of LocalService. I'm running in 2003Server,...
3
by: Liz | last post by:
I was intending to use an XCOPY install for a VS2005 C# WinForms app but when I copied the files and ran the app on a clean machine it failed when it needed Crystal Reports. Can you not use XCOPY...
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: 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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
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,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

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.