473,651 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Batchfile with xcopy

Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInf o
Dim sa As New ArrayList
Dim s As String
Try
With info
..FileName = "c:\test.ba t"
..RedirectStand ardError = True
..UseShellExecu te = False
..RedirectStand ardOutput = True
End With
p = Process.Start(i nfo)
While Not (p.HasExited)
End While
sa.Add("Standar dError: " & p.StandardError .ReadToEnd())
sa.Add("Standar dOutput: " & p.StandardOutpu t.ReadToEnd())
sa.Add("ExitCod e: " & p.ExitCode)
sa.Add("ExitTim e: " & p.ExitTime)
sa.Add("HasExit ed: " & p.HasExited)
Catch ex As Exception
sa.Add("Excepti on: " & 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 2885
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.d e> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInf o
Dim sa As New ArrayList
Dim s As String
Try
With info
.FileName = "c:\test.ba t"
.RedirectStanda rdError = True
.UseShellExecut e = False
.RedirectStanda rdOutput = True
End With
p = Process.Start(i nfo)
While Not (p.HasExited)
End While
sa.Add("Standar dError: " & p.StandardError .ReadToEnd())
sa.Add("Standar dOutput: " & p.StandardOutpu t.ReadToEnd())
sa.Add("ExitCod e: " & p.ExitCode)
sa.Add("ExitTim e: " & p.ExitTime)
sa.Add("HasExit ed: " & p.HasExited)
Catch ex As Exception
sa.Add("Excepti on: " & 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(i nfo) 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("Here 1")
p.WaitForExit()
WriteLine("Here 2")

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_inser t@tralala_tenfo rce.com> wrote in
message news:er******** ******@TK2MSFTN GP10.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.d e> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInf o
Dim sa As New ArrayList
Dim s As String
Try
With info
.FileName = "c:\test.ba t"
.RedirectStanda rdError = True
.UseShellExecut e = False
.RedirectStanda rdOutput = True
End With
p = Process.Start(i nfo)
While Not (p.HasExited)
End While
sa.Add("Standar dError: " & p.StandardError .ReadToEnd())
sa.Add("Standar dOutput: " & p.StandardOutpu t.ReadToEnd())
sa.Add("ExitCod e: " & p.ExitCode)
sa.Add("ExitTim e: " & p.ExitTime)
sa.Add("HasExit ed: " & p.HasExited)
Catch ex As Exception
sa.Add("Excepti on: " & 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.d e> wrote in message
news:Or******** ******@TK2MSFTN GP09.phx.gbl...
My problem is, that the code behind the p = Process.Start(i nfo) 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("Here 1")
p.WaitForExit()
WriteLine("Here 2")

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_inser t@tralala_tenfo rce.com> wrote in
message news:er******** ******@TK2MSFTN GP10.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.d e> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi.

I have this code:

Dim p As New Process
Dim info As New ProcessStartInf o
Dim sa As New ArrayList
Dim s As String
Try
With info
.FileName = "c:\test.ba t"
.RedirectStanda rdError = True
.UseShellExecut e = False
.RedirectStanda rdOutput = True
End With
p = Process.Start(i nfo)
While Not (p.HasExited)
End While
sa.Add("Standar dError: " & p.StandardError .ReadToEnd())
sa.Add("Standar dOutput: " & p.StandardOutpu t.ReadToEnd())
sa.Add("ExitCod e: " & p.ExitCode)
sa.Add("ExitTim e: " & p.ExitTime)
sa.Add("HasExit ed: " & p.HasExited)
Catch ex As Exception
sa.Add("Excepti on: " & 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_inser t@tralala_tenfo rce.com> wrote in
message news:eg******** ******@TK2MSFTN GP10.phx.gbl...
strange...
isn't the xcopy waiting for some user input?
"Volker Jobst" <bu****@gmx.d e> wrote in message
news:Or******** ******@TK2MSFTN GP09.phx.gbl...
My problem is, that the code behind the p = Process.Start(i nfo) 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("Here 1")
p.WaitForExit()
WriteLine("Here 2")

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_inser t@tralala_tenfo rce.com> wrote in
message news:er******** ******@TK2MSFTN GP10.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.d e> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> Hi.
>
> I have this code:
>
> Dim p As New Process
> Dim info As New ProcessStartInf o
> Dim sa As New ArrayList
> Dim s As String
> Try
> With info
> .FileName = "c:\test.ba t"
> .RedirectStanda rdError = True
> .UseShellExecut e = False
> .RedirectStanda rdOutput = True
> End With
> p = Process.Start(i nfo)
> While Not (p.HasExited)
> End While
> sa.Add("Standar dError: " & p.StandardError .ReadToEnd())
> sa.Add("Standar dOutput: " & p.StandardOutpu t.ReadToEnd())
> sa.Add("ExitCod e: " & p.ExitCode)
> sa.Add("ExitTim e: " & p.ExitTime)
> sa.Add("HasExit ed: " & p.HasExited)
> Catch ex As Exception
> sa.Add("Excepti on: " & 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.tx t
and it works fine now.

"Volker Jobst" <bu****@gmx.d e> wrote in message
news:OS******** ******@TK2MSFTN GP10.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_inser t@tralala_tenfo rce.com> wrote in
message news:eg******** ******@TK2MSFTN GP10.phx.gbl...
strange...
isn't the xcopy waiting for some user input?
"Volker Jobst" <bu****@gmx.d e> wrote in message
news:Or******** ******@TK2MSFTN GP09.phx.gbl...
My problem is, that the code behind the p = Process.Start(i nfo) 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("Here 1")
p.WaitForExit()
WriteLine("Here 2")

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_inser t@tralala_tenfo rce.com> wrote in message news:er******** ******@TK2MSFTN GP10.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.d e> wrote in message
> news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
> > Hi.
> >
> > I have this code:
> >
> > Dim p As New Process
> > Dim info As New ProcessStartInf o
> > Dim sa As New ArrayList
> > Dim s As String
> > Try
> > With info
> > .FileName = "c:\test.ba t"
> > .RedirectStanda rdError = True
> > .UseShellExecut e = False
> > .RedirectStanda rdOutput = True
> > End With
> > p = Process.Start(i nfo)
> > While Not (p.HasExited)
> > End While
> > sa.Add("Standar dError: " & p.StandardError .ReadToEnd())
> > sa.Add("Standar dOutput: " & p.StandardOutpu t.ReadToEnd())
> > sa.Add("ExitCod e: " & p.ExitCode)
> > sa.Add("ExitTim e: " & p.ExitTime)
> > sa.Add("HasExit ed: " & p.HasExited)
> > Catch ex As Exception
> > sa.Add("Excepti on: " & 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
8782
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 me the error message with 'Invalid Drive Specification'. My whole process includes 1) set up linked server connection on the standby server 2) set up job to xcopy file as operating system commend in sql server from the production box(xcopy...
3
2100
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 of the installation needs to "dump" a bunch of files (third party product's project files) to the user's system. These files are transient in nature in that the user may choose
6
22500
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 ProcessArguments ) { string ErrorStream = ""; Process DOSProcess = new Process();
2
1747
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 xcopy. After doing some simple development via vs.net I found that xcopy'ing my app from a development workstation to the production server didn't work, but I easily dealt with that problem via vs.net's "copy project" menu command. I assume that...
2
2197
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 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...
1
2396
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 able to do exactly what we want them to do - or at least not easily. So now i am looking into the possibly of using an xcopy deployment. However - i can find very little information about the major disadvantages of this method. Does anyone...
1
1863
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 "; ...
1
1989
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, so its not a vista issue. Any ideas why i cannot do this xcopy from my installer, yet it works fine from console program? Process kafInstallProcess = new Process();
3
2066
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 deployment if you have Crystal Reports dependencies? Is there an available Crystal redistribution package I can run before doing my XCOPY deployment? TIA
0
8361
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8701
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
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,...
0
8584
tracyyun
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...
0
7299
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
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 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...
0
5615
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();...
1
1912
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
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...

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.