5 Replies - 5118 Views - Last Post: 06 January 2011 - 05:51 PM Rate Topic: -----

#1 mafia_hitman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 01-January 11

Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 03:36 PM

Hi Everybody there
I'm Having a probleme whit coping files or deleting them
For exemple i want to delete a file in program file



For Deleting Files I Have That problem when i Use:
Kill(Target File)

But the problem is like that (Info: the program is not running):

Quote

Access to the path 'C:\Program Files\Apple Software Update\SoftwareUpdate.exe' is denied.


The Seconde problem thant when i want to copy a file to a directory that the file exist
it gave to me a chose to replace or copy file whit other name ..
I want copying fil and replacing a without showing any message

Is This A Good Question/Topic? 0
  • +

Replies To: Force Deleting Files + Replacing Files (Help)

#2 hlx  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 31
  • View blog
  • Posts: 135
  • Joined: 13-November 10

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 03:41 PM

Can you post us your source, plus what OS you are running this on? Is this VB express or paid for?
Was This Post Helpful? 0
  • +
  • -

#3 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 04:02 PM

Yeah. The kill command won't force delete (regardless of permissions). The user will need to run your application as administrator, and then you'll have to perform a delete on reboot to make absolutely sure a file/folder is deleted regardless of permissions. Even then, most anti viruses will have some sort of low level protection in the kernel against that kind of thing.

You can get windows to delete files on reboot from the registry (take a look at this, scroll down to the bottom for solution, ignore the subscribe thingy.)

This post has been edited by Jack Eagles1: 06 January 2011 - 04:10 PM

Was This Post Helpful? 0
  • +
  • -

#4 mafia_hitman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 01-January 11

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 04:27 PM

Thanks :$
this is the code

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        IO.File.WriteAllBytes(IO.Path.Combine(Environment.GetEnvironmentVariable("Temp"), "SoftwareUpdate.exe"), My.Resources.[SoftwareUpdate])
        If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Aegisub", "TestValue", Nothing) Then
            MsgBox("The Program Is Not installed !! Install it first")
        End If
        If IsProcessRunning("SoftwareUpdate") Then
            Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("SoftwareUpdate")
            For Each p As Process In pProcess
                p.Kill()
            Next
        End If
        If IO.File.Exists("C:\Program Files\Apple Software Update\SoftwareUpdate.exe") Then

            Dim Dir As String
            Dir = System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) & "\Apple Software Update\SoftwareUpdate.exe"
            File.Delete("C:\Program Files\Apple Software Update\SoftwareUpdate.exe")
            My.Computer.FileSystem.CopyFile( _
                (System.IO.Path.GetTempPath & "SoftwareUpdate.exe"), _
                "C:\Program Files\Apple Software Update\SoftwareUpdate.exe", _
                FileIO.UIOption.AllDialogs, _
                FileIO.UICancelOption.DoNothing)
        Else
            MsgBox("File not found.")
        End If
    End Sub


waiting solution
Was This Post Helpful? 0
  • +
  • -

#5 xnn  Icon User is offline

  • D.I.C Head

Reputation: 36
  • View blog
  • Posts: 227
  • Joined: 10-February 10

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 05:06 PM

You will need to wait for the process to release the file before being able to overwrite it. To copy without prompt either delete the file that exists in the destination directory or run a bat using xcopy and the correct switches. They can be found on msdn.
Was This Post Helpful? 0
  • +
  • -

#6 mafia_hitman  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 01-January 11

Re: Force Deleting Files + Replacing Files (Help)

Posted 06 January 2011 - 05:51 PM

View Postxnn, on 06 January 2011 - 04:06 PM, said:

You will need to wait for the process to release the file before being able to overwrite it. To copy without prompt either delete the file that exists in the destination directory or run a bat using xcopy and the correct switches. They can be found on msdn.

ya thanks man :D
i have fixed the probleeem
thanks for all :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1