Click here to Skip to main content
15,896,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have used a simple get file method but the scan stops because the file path being checked is access denied. How can I set the program to have full access to all files in the computer.

the code is as follows

VB
Imports System.IO
Public Class Form1
    Private Sub btnScan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnscan.Click
        btnscan.Enabled = False
        Dim searchForTheseFiles() As String = txtFileList.Text.ToUpper.Split(Environment.NewLine)
        Dim fileList As New List(Of String)(searchForTheseFiles)
        Dim myDir As New DirectoryInfo(cboDriveList.Text)
        For Each foundFile As FileInfo In myDir.GetFiles("*.*", SearchOption.AllDirectories)
            If fileList.Contains(foundFile.Name.ToUpper) Then
                MsgBox("AAAAAHHHHH!!!! VIRUS FOUND!!!")

                textbox1.Text &= Environment.NewLine & foundFile.FullName
                Try
                    foundFile.Delete()
                Catch ex As Exception
                    MsgBox("Couldn't delete infected file!")
                    textbox1.Text &= String.Format("{0}Couldn't delete infected file: {1}", Environment.NewLine, foundFile.FullName)
                End Try
            End If
        Next foundFile
        btnscan.Enabled = True
    End Sub

    Private Function foundFile() As Object
        Throw New NotImplementedException
    End Function

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cboDriveList.Items.AddRange(System.IO.Directory.GetLogicalDrives)
    End Sub
End Class


thank you in advance
Posted
Updated 18-Oct-10 8:15am
v2
Comments
Marc A. Brown 18-Oct-10 14:15pm    
EDIT: Fixed code formatting.

1 solution

The software will be executed under your account (account of the user that starts the application). This also means that the application has the same rights as that user. So, to get access to these files you would need to provide access to that account.

You understand that otherwise there would be no security what so ever built in the OS. But, luckily most people don't use an actual OS but they use Windows (the place where viruses and, not to forget, virus-scanners live;-))

As you might have noticed a virus or virus-scanner (there is no actual difference) is not working alone and has several processes for different tasks. The trick is that an application, in most cases, have Internet access but cannot access all of the system. For windows this means that there is also an account that does not have internet/network access but does has access to the rest of the system. Should sound very good right? Because for your virus scanner you could use this... but likewise you, or anyone else, can use this for virus development :-D . LocalSystem is something you could use. A nice service supplies rights for local "system administration" and for example a user mode application for some other things. This only needs a simple communication mechanism of some sort and there you go, the combined rights of both worlds! Isn't it great! ;)

Good luck!
 
Share this answer
 
Comments
Dale 2012 18-Oct-10 16:01pm    
ok so maybe you can let me in on the perticulars of the facts you have stated...........
E.F. Nijboer 19-Oct-10 3:48am    
About above, a service is running as LocalSystem so that's something to get into.
Also, take a look here: http://www.codeproject.com/KB/security/UB_CAS_NET.aspx
Other useful information would be on token privileges. http://winterdom.com/dev/security/tokens
Another very nice page on information about windows is this: http://www.geoffchappell.com/viewer.htm?doc=index.htm
The rest is up to you because you would really need to get into it because it's not something that can be explained in a few words.
Dale 2012 19-Oct-10 16:59pm    
thank you I will check it out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900