473,385 Members | 1,615 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.

How to replace process file itself?

yxq
Hello,
I want to update A program file from A.
First startup A, then startup B process from A, close A, B will copy new
file to replace A file.
But system states that A is using.

A code:
////////////////////////////////////////////
Dim objProcess As New Process
objProcess.StartInfo.FileName = "B.exe"
objProcess.Start()
Me.Close()

B code:
///////////////////////////////////////////
IO.File.Copy(NewFile, A.exe, True)

Thank you.
Aug 28 '07 #1
2 1644
On Aug 28, 8:12 am, "yxq" <ga...@163.netwrote:
Hello,
I want to update A program file from A.
First startup A, then startup B process from A, close A, B will copy new
file to replace A file.
But system states that A is using.

A code:
////////////////////////////////////////////
Dim objProcess As New Process
objProcess.StartInfo.FileName = "B.exe"
objProcess.Start()
Me.Close()

B code:
///////////////////////////////////////////
IO.File.Copy(NewFile, A.exe, True)

Thank you.
How much time are you giving "A" to close before trying to run the
code in "B"?

Thanks,

Seth Rowe

Aug 28 '07 #2
yxq wrote:
I want to update A program file from A.
First startup A, then startup B process from A, close A, B will copy new
file to replace A file.
But system states that A is using.

A code:
////////////////////////////////////////////
Dim objProcess As New Process
objProcess.StartInfo.FileName = "B.exe"
objProcess.Start()
Me.Close()

B code:
///////////////////////////////////////////
IO.File.Copy(NewFile, A.exe, True)
It /may/ be that B is simply starting up too quickly for the process
running A to get out of the way.

Add a delay (of a few seconds) to the startup code in B and see if that
makes any difference:

Module B
Shared Function Main( ByVal args() as String ) As Integer
System.Threading.Thread.Sleep( 15000 )
System.IO.File.Copy( "A+.exe", "A.exe", True )
Return 0

HTH,
Phill W.
Aug 28 '07 #3

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

Similar topics

7
by: Joshua Beall | last post by:
Hi All, I am doing some work where I want to do locking, and prevent scripts from running in parallel. I see that I could use the semaphore mechanism, but I'd like for my code to be portable,...
1
by: Christine Forber | last post by:
I have the following situation. On one page, a user clicks on a link which triggers a server-side program to generate the requested output PDF. Depending on the specifics of the PDF being...
9
by: gulu man | last post by:
Hi, What is the substitute for COM objects in .NET? How can I create something similar to com in .net? Is it still possible? Thank you
4
by: BCM | last post by:
In a simple console app the following few lines open up an Acrobat file without a hitch: Process p = new Process(); p.StartInfo.FileName = @"C:\test.pdf"; p.Start(); But the same code in an...
7
by: WALDO | last post by:
I wrote a console application that basically consumes arguments and starts other command line apps via System.Process. Let's call it XCompile for now. I wrote a Visual basic add-in that does pretty...
4
by: serge | last post by:
I managed to put together C# code and have it do the following: 1- Get all the table names that start with the letter "Z" from sysobjects of my SQL 2000 database and put these table names...
12
by: Michael | last post by:
In PHP there is a function called str_replace (http://php.net/str_replace). Basically you can freed in two strings and a "subject" string. Then it goes through the subject string searching for...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
6
by: DataSmash | last post by:
Hello, I need to search and replace 4 words in a text file. Below is my attempt at it, but this code appends a copy of the text file within itself 4 times. Can someone help me out. Thanks! #...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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
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,...

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.