[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

process object locking up files

Posted on 2006-11-11
13
Medium Priority
?
221 Views
Last Modified: 2010-04-23
 when i have the .createnowindow=True, whenever the copy command is done, it never releases the copied file. I try to delete d:\test.txt when done, and it says being used by another process.

when i put the createnowindow=False it does not do this, but i get a shell pop up window where can see copy going on.
Isn't there a property to keep the createnowindow=True, but hide the window itself?
         
  Dim cmdFile As New Process
            With cmdFile.StartInfo
                .FileName = "cmd.exe"
                .arguments ="/c copy c:\test.txt d:\test.txt"
                .CreateNoWindow = True
                .UseShellExecute = True
            End With
            cmdFile.Start()
            cmdFile.WaitForExit(-1)
            cmdFile.Dispose()
           
0
Comment
Question by:rkneal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
13 Comments
 
LVL 48

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 17924248
If you are only copying files, it is better to use something like this....

    System.IO.File.Copy("C:\text.txt", "D:\test.txt", True)

Regards,

Wayne
0
 

Author Comment

by:rkneal
ID: 17924258
sorry, i should have said in last post, that we are really running a very detailed windows volume shadow copy, so the above filename is really a .bat file that gets run by the process command.   It is copying about 1G of data over a network from a proprietary system.   As stated above if i put the .createOnWindow=True it does not lock up the files, but i can see the window pop up.
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17924618
Did you try calling the batch file only without cmd.exe it should work and do what you want
also use xcopy better.

Process.Start("xcopy", "c:\test.txt d:\test.txt")
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17924619
And try it with .createwindow = false it should be ok ...
0
 
LVL 7

Accepted Solution

by:
Mohamed Zedan earned 1000 total points
ID: 17924645
Sorry this is what I meant

        Dim pInfo As New ProcessStartInfo("xcopy", "c:\test.txt d:\test.txt")
        pInfo.CreateNoWindow = False
        pInfo.WindowStyle = ProcessWindowStyle.Hidden
        Process.Start(pInfo)
0
 

Author Comment

by:rkneal
ID: 17925077
we can't use xcopy, it does not allow to copy open files.
if you look at the windows volume copy service, it allows you to copy open files so this is the mechanism we use to do this.

But, your answer above is allowing me to control the window state of the command window, so it works!

thanks
Bob
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17925090
Glad it helped :)
0
 

Author Comment

by:rkneal
ID: 17925091
followup comment, i had to still make the .useshellexecute = true to make this not lock up the files, :)

  Dim cmdfile As New ProcessStartInfo
            With cmdfile
                .FileName = rFileStr
                '.RedirectStandardOutput = True
                .CreateNoWindow = True
                .UseShellExecute = True
                cmdfile.WindowStyle = ProcessWindowStyle.Hidden
            End With

            Process.Start(cmdfile)
            Process.Start(cmdfile).WaitForExit(1000)
            Process.Start(cmdfile).Dispose()
0
 

Author Comment

by:rkneal
ID: 17925095
thanks again!, at least not one can see the window popping up with your solution to control the processWindowStyle property.
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17925099
These lines cause you to call the copy three times

Process.Start(cmdfile)
Process.Start(cmdfile).WaitForExit(1000)
Process.Start(cmdfile).Dispose()

instead do this....

dim p as process = new process
p.start(cmdFile)
p.waitforexit(1000)
p.dispose
0
 
LVL 7

Expert Comment

by:Mohamed Zedan
ID: 17925102
you're welcome again .... :) but see the comment above ^^^
0
 

Author Comment

by:rkneal
ID: 17925110
i see! thanks
0
 

Author Comment

by:rkneal
ID: 17926113
just a last comment, i downloaded a free program called unlocker.  This allowed me to see who was locking the files. Ends up being the vb.net app was not locking them, but McAfee antivirus!!  This unlocker program allows you to see that, then tell it to unlock it. Pretty cool for free

Thanks for help.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question