0

I am developing an application that unhides folders and files that were hidden by a virus in windows PC's using visual studio 2012. And I'm developing it using WindowsFormsApplication. So my question is after i have received the users preferred drive using FolderBrowserDialog, how can i make my application execute an unhide command using cmd.exe like "attrib -s -h /s /d ." on the drive that the user selects?

Its not much but, here is what i'hv done so far:

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If FolderBrowserDialog1.ShowDialog = DialogResult.OK Then
            TextBox1.Text = FolderBrowserDialog1.SelectedPath
            Label1.Text = command

        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

    End Sub
End Class

So when the user clicks Button_2 i want the application to execute a cmd command to unhide files and folders on the selected drive. Any idea how i can achieve that?

Am @ the very beginners level, so detailed & simplified answers will be appreciated. Thanks all.

  • Your question is really too broad to get a complete answer here. You could start searching on the property [FileSystemInfo.Attributes](https://msdn.microsoft.com/en-us/library/system.io.filesysteminfo.attributes(v=vs.110).aspx), then, if you have difficulties post a new question with the code that you have written – Steve Dec 23 '15 at 14:04
  • @Steve, I have posted my code and detailed question. – Aaron Dolphin Dec 23 '15 at 14:33
  • I think [this question](http://stackoverflow.com/q/8795723/4519059) can help you ;). – shA.t Dec 23 '15 at 14:47

1 Answers1

0

This is from MSDN

Imports System
Imports System.IO
Imports System.Text

Public Class Test
 Public Shared Sub Main()
    Dim path As String = "c:\temp\MyTest.txt"

    ' Create the file if it does not exist.
    If File.Exists(path) = False Then
        File.Create(path)
    End If

    Dim attributes As FileAttributes
    attributes = File.GetAttributes(path)

    If (attributes And FileAttributes.Hidden) = FileAttributes.Hidden Then
        ' Show the file.
        attributes = RemoveAttribute(attributes, FileAttributes.Hidden)
        File.SetAttributes(path, attributes)
        Console.WriteLine("The {0} file is no longer hidden.", path)
    Else
        ' Hide the file.
        File.SetAttributes(path, File.GetAttributes(path) Or FileAttributes.Hidden)
        Console.WriteLine("The {0} file is now hidden.", path)
    End If
 End Sub

 Public Shared Function RemoveAttribute(ByVal attributes As FileAttributes, ByVal attributesToRemove As FileAttributes) As FileAttributes
    Return attributes And (Not attributesToRemove)
 End Function
End Class

You have to change it to do what you want, and do search all the folders and subfolders but it should be a good start.