472,958 Members | 2,169 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 2855
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.